I am not an expert in node and async.js. So expecting help from node js community. So here is my scenario, I want to do 3 operation one after one, each depends on previous result. By using previous result i need to call async function to retrieve another result. So I decided to go with async waterfall. (Hope I chose correct one).
async.waterfall([
function(callback) {
request({
method: 'GET',
headers: {'Content-Type' : 'application/json'},
url : url
},function(error, response, body){
if(error) {
callback(error);
} else {
var result= JSON.parse(body);
callback(null,result); //sending to next function
}
});
},
function(result, callback) {
//here i want to use the result array in loop async.eachSeries or forEachSeries and fetch another result array using request module then send it to next function
/*Here I don't know How to process the result*/
callback(null,result1)
},
function(result1, callback) {
//here i want to use the result1 array and fetch another result array then send it to next function
callback(null,result2)
}
], function(error, res) {
console.log(res); // process final result
});
I referred some tutorials. I couldn't understand that's why end up here in SO. Thanks in advance.