Created
January 20, 2015 16:19
-
-
Save seanstrom/e903d7e0e36d4bebc864 to your computer and use it in GitHub Desktop.
Async JS/Node - Create Promise Example
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 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