Skip to content

Instantly share code, notes, and snippets.

@yoelfme
Created March 15, 2016 19:10
Show Gist options
  • Select an option

  • Save yoelfme/fe33a52fb917c3ddc58a to your computer and use it in GitHub Desktop.

Select an option

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