Skip to content

Instantly share code, notes, and snippets.

@kartikpandey2
Created April 30, 2019 06:28
Show Gist options
  • Save kartikpandey2/979d6e7659d9401a595f94d9114e1ea2 to your computer and use it in GitHub Desktop.
Save kartikpandey2/979d6e7659d9401a595f94d9114e1ea2 to your computer and use it in GitHub Desktop.
const multipleFetch = async () => {
const Fetch1 = await fetch(url, options)
/*
* Fetch1 has completed, Do required things after fetch1
*/
const Fetch2 = await fetch(url, options)
/*
* Fetch1 and Fetch2 has completed, Do required things after fetch2
*/
const Fetch3 = await fetch(url, options)
/*
* Fetch1,Fetch2 and Fetch3 has completed, Do required things after fetch3
*/
const Fetch4 = await fetch(url, options)
/*
* Fetch1, Fetch2, Fetch3 and Fetch4 has completed, Do required things after fetch4
*/
}
const performanceFetch = async () => {
const urlArray = ["url1", "url2", "url3", "url4", "url5",]
const promiseArray = urlArray.map((url) => fetch(url))
const arrayOfResponse = await Promise.all(promiseArray)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment