This is a great article. I had trouble understanding the last example without async await but with promises. I knew promise.all takes promises array as an argument, but why did we write promise in each fetch call? Can u explain a little
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a great article. I had trouble understanding the last example without async await but with promises. I knew promise.all takes promises array as an argument, but why did we write promise in each fetch call? Can u explain a little
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.