Skip to content

Instantly share code, notes, and snippets.

@hiun
Created September 20, 2015 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiun/8ac444127b04346ad446 to your computer and use it in GitHub Desktop.
Save hiun/8ac444127b04346ad446 to your computer and use it in GitHub Desktop.
Multiple Request with Promise
var request = require('request');
Promise.resolve(request(args1, arg2, arg3)).then(function (response, html) { //no error arg here!
//parsing with cheerio
return request(newArg1);
}).then(function () {
//parsing multiple article
return [
request(newArg2),
request(newArg3),
request(newArgN)
]
}).spread(function (rslt1, rslt2, rsltN) {
return doAnotherAsyncTask()
}).catch(errHdr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment