I am new in NODE-JS, stuck on basic functionality, I have four sequentially executed async methods, they must be executed sequentially. you may check POST event==>progression method.
I have 2 issues
1)How to set promise.all when there is any error raise want to rollback, is there any better approach please share with me.
2)It's a concurrently requested POST method, need to execute parallelly, or any best approach to handle concurrent method.
  Task-1 getCompanyAssociatedDeals
  Task-2 getDealInformation
  Task-3 createDeal
  Task-4 updateCompanyDeal
async function getCompanyAssociatedDeals(companyId) {
  try {    
    return result;
  } catch (error) {}
}
async function getDealInformation(dealId) {
  try {    
    return result;
  } catch (error) {}
}
async function createDeal(totalDealAmount, companyId) {
  try 
  {   
    return newMergeDeal;
  } catch (error) {
    console.log("Error on creation");
  }
}
async function updateCompanyDeal(totalDealAmount, companyId) {
  try 
  {   
    return updatedDeal;
  } catch (error) {
    console.log("Error on creation");
  }
}
app.post("/progression", async (req, res) => {
  
  const associatedDeals = await getCompanyAssociatedDeals(req.body.objectId);  
  let totalDealAmount = 0;
  for (let deal of associatedDeals.results) {
    let currentDeal = await getDealInformation(deal);
    totalDealAmount += Number(currentDeal.properties.amount.value);
  }
  
  if (totalDealAmount) {
    
    let newMergeDeal = await createDeal(totalDealAmount, req.body.objectId);    
    await updateCompanyDeal(totalDealAmount, req.body.objectId);
    
    return res.status(200).send("new Merge Deal " + newMergeDeal.dealId);
  }
  return res.status(200).send("success" + req.body.objectId);
});
Note: Task-1 output result needs to use in Task-2, Task-3 output result needs to used in Task-3 and Task-4.
Following Promise syntax may not help me to used one task output result to another one
await Promise.all([Task-1(),Task-2(),Task-3(),Task-4()]);
