Promise
const url = ['www.url1.com', 'www.url2.com', 'www.url3.com']
Promise.all(urls.map(url => {
return fetch(url).then(resp => resp.json())
})).then(results => {
console.log(result[0])
console.log(result[1])
console.log(result[2])
}).catch(() => console.log('error')
With Async Await
const [users, posts, todos] = await Promise.all(urls.map(url => {
return fetch(url).then(resp => resp.json())
}))
console.log('users', users)
console.log('posts', posts)
console.log('todos', todos)Last updated