I use this function
await getTestData(entry).then(res=> {
for(let i = 0; i < res.length; i++){
//console.log(res[0].data)
console.log("line");
}
}).catch(error => {
console.log("MongoGetError");
});
console.log("end");
The result is
- line
- end
Now I have to put this into a .forEach()
loop. I tried:
testcases.forEach(async function(entry,index) {
await getTestData(entry).then(res=> {
for(let i = 0; i < res.length; i++){
//console.log(res[0].data)
console.log("line");
}
}).catch(error => {
console.log("MongoGetError");
});
});
console.log("End");
But the result is:
- End
- line
- line
What is my fault to get finally
- line
- line
- end