Created
March 15, 2016 19:10
-
-
Save yoelfme/fe33a52fb917c3ddc58a to your computer and use it in GitHub Desktop.
How to make a promise with the package 'q' in Node.js
This file contains 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
function myPromise() { | |
let deferred = Q.defer() | |
myRequest(options, function (err, body)) { | |
if (err) { | |
deferred.reject(err) | |
} | |
deferred.resolve(body) | |
}) | |
return deferred.promise | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment