Skip to content

Instantly share code, notes, and snippets.

@seanstrom
Created January 20, 2015 16:19
Show Gist options
  • Save seanstrom/e903d7e0e36d4bebc864 to your computer and use it in GitHub Desktop.
Save seanstrom/e903d7e0e36d4bebc864 to your computer and use it in GitHub Desktop.
Async JS/Node - Create Promise Example
var http = require('special-http')
function getData(endpoint) {
var promise = new Promise(function(resolver, rejector) {
http.get(endpoint).then(function(data) {
resolver(data)
}, function(err) {
rejector(err)
})
})
return promise
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment