I have the following loop in node.js
for (var i in details) {
if (!details[i].AmntRcvd > 0) {
res.sendStatus(400);
return;
}
totalReceived
You can use the await
keyword to solve this. more info here
async function main() {
for (var i in details) {
if (!details[i].AmntRcvd > 0) {
res.sendStatus(400);
return;
}
try {
totalReceived += details[i].AmntRcvd;
let results = await UpdateDetail(details[i].PONbr, details[i].LineID);
console.log(results);
details[i].QtyOrd = results.QtyOrd;
details[i].QtyRcvd = results.QtyRcvd;
details[i].QtyPnding = results.QtyPnding;
details[i].UnitCost = results.UnitCost;
}
catch(e) {
console.log(error);
}
}
}