Skip to content

Instantly share code, notes, and snippets.

@yoelfme
Created March 15, 2016 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoelfme/fe33a52fb917c3ddc58a to your computer and use it in GitHub Desktop.
Save yoelfme/fe33a52fb917c3ddc58a to your computer and use it in GitHub Desktop.
How to make a promise with the package 'q' in Node.js
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