Last active
August 29, 2015 14:17
-
-
Save kt3k/b7b4376e88b9c859e53e to your computer and use it in GitHub Desktop.
superagent-make-promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var superagent = require('superagent'); | |
var Promise = require('es6-promise').Promise; | |
superagent.Request.prototype.makePromise = function (request) { | |
var that = this; | |
return new Promise(function (resolve, reject) { | |
that.end(function (error, response) { | |
if (error) { | |
reject(error); | |
return; | |
} | |
resolve(response); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment