'Proper way to make various concurrent calls in JS and await them all?

Consider the following:

async makesomething () {
  // These first calls should all be done concurrent...
  call1()
  call2()
  call3()
  // But I want to wait all the previous call to finish before calling call4()
  call4()
}

Adding an await before call1-2() will make the next call wait for it to finish, which is not the desired behavior... And if I add it on call3, call4 might happen before call1-2 finishes which again is not the desired behavior here... So how do I make call4 wait for the previous calls to finish without blocking any of the previous calls?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source