This is my code
function performComputation(Name){
var x="";
Promise.all([model.find({Name:Name}).exec()])
.then(results => {
x = doSomething(results[0]['name']);
});
return x;
}
function getAllComputation(data){
var result="";
for(var member of data){
result=result.concat(performComputation(member['Name']));
}
return result;
}
getallComputation(someData);
My function getAllComputation is looping through data and generating multiple async operations but I want to wait and return a concatenation of all the computations , right now i am getting result as undefined because .find and dosomething are async , how can I wait for all operations to finish.