I have tried to call a database operation from async for each loop. I have the following code
let succussCounter = 0;
let failureCounter = 0;
let mydata=[101,102,104,105];
myData.forEach(async data => {
let response =
await DbConnector.updateSampleTable(data);
if(response){
succussCounter ++;
}else{
failureCounter++;
}
});
console.log('succussCounter = ' + succussCounter);
console.log('failureCounter = ' + failureCounter);
I want to print the success count & failure count after completing the whole loop. But this always prints both are 0.