DEV Community

Discussion on: Dealing with Promises In an Array with async/await

Collapse
 
inneroot profile image
Gleb

You forget about for await to run async functions one-by-one

async function start() {
  for await (let asyncFunction of asyncFunctions ) {
    console.log(await asyncFunction())
  }
}
start();
Enter fullscreen mode Exit fullscreen mode
Collapse
 
afifsohaili profile image
Afif Sohaili

Updated!

Collapse
 
iranrodrigues profile image
iranrodrigues

An added bonus is that you can easily break or return based on the result of each function, if you had to.