Reputation: 3715
I am new to using Nodejs. How to make multiple http calls in parallel and send consolidate response.
Regards, Pradeep
Upvotes: 0
Views: 281
Reputation: 1142
You can use async module. This is from https://github.com/caolan/async
// an example using an object instead of an array
async.parallel({
one: function(callback){
setTimeout(function(){
callback(null, 1);
}, 200);
},
two: function(callback){
setTimeout(function(){
callback(null, 2);
}, 100);
}
},
function(err, results) {
// results is now equals to: {one: 1, two: 2}
});
Upvotes: 1