How to call async/await functions in parallel with Node.js?

Sometimes, we want to call async/await functions in parallel with Node.js.

In this article, we’ll look at how to call async/await functions in parallel with Node.js.

How to call async/await functions in parallel with Node.js?

To call async/await functions in parallel with Node.js, we can call Promise.all.

For instance, we write

await Promise.all([someCall(), anotherCall()]);

to call Promise.all with an array of promises.

We use await to wait for all promises to resolve until we move onto the next line.

And we can store the resolved values with

const [someResult, anotherResult] = await Promise.all([someCall(), anotherCall()]);

Conclusion

To call async/await functions in parallel with Node.js, we can call Promise.all.