Avoid Listener leaks by setting a max answer threshold

This commit is contained in:
Mahdi Dibaiee
2015-07-15 21:11:33 +04:30
parent fbe8d501a7
commit 2dd3dd2e80
5 changed files with 29 additions and 2 deletions

View File

@ -47,7 +47,7 @@ function fetch(path) {
}
_unirest2['default'].post('https://api.telegram.org/bot' + path).field(data).attach(files).end(function (response) {
if (response.statusType === 4 || response.statusType === 5) {
if (response.statusType === 4 || response.statusType === 5 || !response.body.ok) {
reject(response);
} else {
resolve(response.body);