Created
September 30, 2017 07:56
-
-
Save tkssharma/4deb902d12c9a1867fc4f2c074dff824 to your computer and use it in GitHub Desktop.
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 | |
} | |
var promise = getData('/api') | |
promise.then(function(data){ | |
console.log(data) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment