In my node.js application i want to make my flow synchronous. I faced this kind of issues previously, i solved it. But now i am struggling now in this situation.
for(var k=nearestMatchLength;k--;) {
async.forEach(matchedArray[i].nearestmatch, function(elem,Callback){
if(condition){
app.models.Schedule.findById(elem.Id, function(err, res){
for(){
};----> for loop
Callback();
});
}
Callback();
});
}
In the above code if(condition) satisfied then the findById(which is async) is called and the Callback(); after that is called before its executes.
My flow should be if it entered into if condition the fetching should be done and then only the next loop should rotate.
Please share your ideas. thanks in advance.
matchedArray[i].nearestmatchan array?elsestatement?forloop must be async too...async.timesfor example.