Skip to content

Instantly share code, notes, and snippets.

@jcbombardelli
Created March 10, 2022 03:06
Show Gist options
  • Select an option

  • Save jcbombardelli/daf35ad3c52cf848c2fffc9e34175a90 to your computer and use it in GitHub Desktop.

Select an option

Save jcbombardelli/daf35ad3c52cf848c2fffc9e34175a90 to your computer and use it in GitHub Desktop.
const pokemons = [135, 7, 123, 86, 26, 132 ]
const promises = pokemons.map(id => {
return fetch(`https://pokeapi.co/api/v2/pokemon/${id}`)
})
Promise.all(promises)
.then(res => {
return Promise.all(res.map(r => r.json()))
})
.then(pokemonsResult => {
pokemonsResult.forEach(pokemon => {
console.log(pokemon.name)
})
})
.catch(err => {
console.error(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment