DEV Community

Discussion on: How to make many http requests with react

Collapse
 
leightondarkins profile image
Leighton Darkins • Edited

I think promise.all() is going to be what you're looking for.

const firstFetch = fetch('some/resource')
const secondFetch = fetch('some/other/resource')

Promise.all([firstFetch, secondFetch])
  .then(values => {
    // do something with values
    // values[0] is the result of firstFetch
    // values[1] is the result of secondFetch
  })
  .catch(error => {
    // handle any errors
  })
Collapse
 
ekimkael profile image
Ekim Kael

Okay! i try it