Skip to content

Instantly share code, notes, and snippets.

@timakin
Last active August 29, 2015 14:19
Show Gist options
  • Save timakin/1d4c781b1e508419f790 to your computer and use it in GitHub Desktop.
Save timakin/1d4c781b1e508419f790 to your computer and use it in GitHub Desktop.
PromiseTest
var request = require('request');
var gurl = 'http://google.com'
var yurl = 'http://yahoo.co.jp'
var testreq = function(url) {
return new Promise(function(resolve, reject) {
request(url, function (error, response, body) {
if (error) {
reject(err);
} else {
resolve(body);
}
});
});
}
Promise.all([testreq(gurl),testreq(yurl)]).then(function(results) {
console.log(results);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment