From d17ab6b93032474f574337c175a52ff60a731a4b Mon Sep 17 00:00:00 2001 From: John Eckhart Date: Thu, 10 Dec 2015 17:28:35 -0500 Subject: [PATCH] Reject the promise if there is an HTTP (or DNS) error --- lib/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 698fb47..de2c89c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -32,7 +32,7 @@ Client.prototype.get = function(path, options) { try { this.client.get(this.baseUrl + path + query, function(data, response){ resolve(data); - }); + }).on('error',reject); } catch(err) { reject(err); @@ -48,7 +48,7 @@ Client.prototype.put = function(path, data, body) { return new Promise(function(resolve, reject) { this.client.put(this.baseUrl + path, args, function(data, response){ resolve(data); - }) + }).on('error', reject); }.bind(this)); };