diff --git a/lib/close.io.js b/lib/close.io.js index 85c3640..4fe93ec 100644 --- a/lib/close.io.js +++ b/lib/close.io.js @@ -1,5 +1,4 @@ 'use strict'; -var deferred = require('node-promise').defer; var request = require('request'); var qs = require('querystring'); @@ -235,25 +234,27 @@ Closeio.prototype._request = function(options) { pass: '' }; options.jar = false; - var d = deferred(); - request(options, function(error, response, body) { - if (!error && response.statusCode === 200) { - d.resolve(JSON.parse(body)); - return; - } - if (error) { - d.reject(error); - return; - } - var rejection; - try { - rejection = JSON.parse(body); - }catch(e){ - rejection = response.statusCode == 200 ? body : response.statusCode; - } - d.reject(rejection); + return new Promise((resolve, reject) => { + request(options, function(error, response, body) { + if (!error && response.statusCode === 200) { + resolve(JSON.parse(body)); + return; + } + if (error) { + reject(error); + return; + } + var rejection; + try { + rejection = JSON.parse(body); + }catch(e){ + rejection = response.statusCode == 200 ? body : response.statusCode; + } + const err = new Error(); + err.data = rejection; + reject(err); + }); }); - return d.promise; }; Closeio.prototype._post = function(path, options) { diff --git a/package.json b/package.json index 5a7dd4e..c174ee2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "test": "./node_modules/mocha/bin/mocha --recursive test/" }, "dependencies": { - "node-promise": "0.5.8", "request": "2.69.0" }, "devDependencies": {