Using Promise.all to collect an array of async results

In the previous recipe, we saw how to trigger multiple asynchronous functions before awaiting their results. We've also seen how well the Promise API and asyc/await operators work together. There are some situations where it is preferable to use the Promise API.

In this recipe, we'll see how to use Promise.all to collect the result of multiple asynchronous operations.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.