I have a scenario like this:
function sendRequest(args){
//some stuff here
request = buildRequest();
return request;
}
function buildRequest(){
//some stuff here
asyncCall1(args,function(err,result){
//some stuff here
asyncCall2(args2, function(err2,result2){
//some stuff here
//final request that is build is here inside async2
return request;//I dont know if this is the correct way
});
});
}
I need the request parameter which is available inside the asynCall2's callback method back to the sendRequest method so that I can return it form there.
I am very new to javascript as well as callbacks..all I need is to stop the execution of sendRequest method till I get the request parameter back from the asyncCalls (also how will I return that request parameter from asyncCall2).
The only constraint is I cannot change the signatures of sendRequest, asyncCall1 and asyncCall2 methods.