diff --git a/lib/telegrambot.js b/lib/telegrambot.js index 8a320d4..aff9f40 100755 --- a/lib/telegrambot.js +++ b/lib/telegrambot.js @@ -46,9 +46,10 @@ TelegramBot.unwrap = function(cb) { // by passing the error object as the first parameter. if (!err && body && body.ok === false) err = TelegramBot.error(body.description, body.error_code, res.statusCode); if (!err && res.statusCode != 200) err = TelegramBot.error('HTTP status ' + res.statusCode + ' returned.', res.statusCode, res.statusCode); - if (err) return cb.apply(self, [err]); - - cb.apply(self, [null, body.result]); + if(cb!=null && cb!=undefined){ + if (err) return cb.apply(self, [err]); + cb.apply(self, [null, body.result]); + } } }