How can I avoid using these nested async loops to improve the code readability and to simplify the debugging process?The goal of my code is to run 3 functions (waComplianceBusiness, waRuleOverview, waConditionOverview) in sequence to process the received data and it does this, but somehow this function is re-called even if its execution didn't end.  I'm asking this question here because I think that the debugging process can be easier and more intuitive if I wouldn't use these asynchronous loops.export default async (req) => {  const report = req.body.webAudits;  if(report.length == 0) return [];   var reportList = [];  for(const item of report.entries()) {    for(const [runIndex, run] of item.runs.entries()) {      const result = await waComplianceBusiness(req, run.id);      var failureList = [];      if (!result.data.overviews) {        continue;      }      const compliance = result.data.overviews[0].compliance;      if(!compliance) {        continue;      }      for(const rule of compliance.entries()) {        const response = await waRuleOverview(req, run.id, rule.id);        const { failedConditions, ruleName } = response.data;        if(response.data.pagesFailed === 0) continue;        for(let condition of failedConditions) {          const request = {            itemId: condition.conditionResult.id,            itemType: condition.conditionResult.idType,            parentId: condition.conditionResult.parentId,            parentType: condition.conditionResult.parentType          }          const body = {            runId: run.id,            ruleId: rule.id,            payload: request          }          const failure = await waConditionOverview(req, body);          const description = failure.data.description;          const conditionValues = failure.data.conditionValues;          var valueList = [];          conditionValues.forEach(item => {            const value = (item.value == ) ? 'empty' : item.value;            if(valueList.indexOf(value) == -1) {              valueList.push(value);            }          })          var actualValue = '';          valueList.forEach((value, v => {            actualValue += value;            if(v > 0) {              actualValue += '\n';            }          });          var expected = description.expected[0] ? description.name + ' ' + description.matcher + ' ' + description.expected[0] : description.name + ' ' + description.matcher          if(description.idType == variable) {            var failureObj = {              ruleName: ruleName,              expected: expected,              actual: description.name + '=' + actualValue,            };          }          else if(description.idType == tag) {            var failureObj = {              ruleName: ruleName,              expected: description.name + '\n' + description.matcher,              actual: actualValue,            };          }          failureList.push(failureObj);        }      }      if(failureList.length > 0) {        item.runs[runIndex].failures = failureList;      }    }  }  return report;}I'm calling this function from the Express route like this:const router = express.Router();router.post('/', authenticate, async (req, res) => {  const webAudits = await webAuditsFailures(req);  res.status(201).json({ reports: webAudits });})export default router;
Node.js how to avoid nested loops to simplify the debugging process
node.js;asynchronous;async await