Created
September 20, 2015 06:23
-
-
Save hiun/8ac444127b04346ad446 to your computer and use it in GitHub Desktop.
Multiple Request with Promise
This file contains 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 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