diff --git a/lib/sender.js b/lib/sender.js index 58a37e4..93d7267 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -157,11 +157,6 @@ Sender.prototype.sendNoRetry = function(message, recipient, callback) { .then((res) => { const { data: resBodyJSON, status } = res; - if (status !== 200) { - debug('Invalid request (' + status + '): ' + resBodyJSON); - return callback(status); - } - if (_.isEmpty(resBodyJSON)) { debug('Empty response received (' + status + ' ' + res.statusText + ')'); // Spoof error code 400 to avoid retrying the request @@ -183,6 +178,12 @@ Sender.prototype.sendNoRetry = function(message, recipient, callback) { debug('GCM service is unavailable (500)'); return callback(res.status); } + + if (res.status !== 200) { + debug('Invalid request (' + res.status + '): ' + res.data); + return callback(res.status); + } + } return callback(err);