Dinoop mathew Dinoop mathew - 4 months ago 12
Node.js Question

How to make multiple http calls from the nodejs server with a common callback?

I want to make multiple http calls in nodejs sever with common callback.
Is there any modules available for doing it?

Answer

I have used this Async NPM to solve this. https://www.npmjs.com/package/async

async.parallel([
        function(callback){
             callback(null,1)
        },
        function(callback){
             callback(null,2)
        },      
    ],
    function(err, results){

       console.log(results); //Output [1,2]

    });
Comments