DEV Community

loading...

Discussion on: for loop vs .map() for making multiple API calls

Collapse
askrishnapravin profile image
Krishna Pravin Author

The last example(using promise) is the same as the previous one(using await).

We have a promise inside fetch because parsing response as json response.json() returns a promise. For each API call, Promise.all() will first wait for the API call's response to arrive, and then it will wait for the json parsing to complete.

When Promise.all takes an array of promises, it will wait for all the inner promises as well to get resolved.