From d7d7f8566b7ed7fff0d788728e1ed7c0d70978e2 Mon Sep 17 00:00:00 2001 From: kytu-home Date: Sun, 27 Dec 2015 16:16:27 +0800 Subject: [PATCH] fix error cause by sometimes body return without data attributes --- lib/imgur.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/imgur.js b/lib/imgur.js index 52974e71..6e321b05 100644 --- a/lib/imgur.js +++ b/lib/imgur.js @@ -84,7 +84,7 @@ imgur._imgurRequest = function (operation, payload, extraFormParams) { if (err) { deferred.reject(err); } else if (!body.success) { - deferred.reject({status: body.status, message: body.data.error}); + deferred.reject({status: body.status, message: body.data ? body.data.error : 'No body data response'}); } else { deferred.resolve(body); }