Skip to content

Instantly share code, notes, and snippets.

@ortense
Created June 24, 2022 21:21
Show Gist options
  • Save ortense/4d214a06baf608d4690703a8a216c6fc to your computer and use it in GitHub Desktop.
Save ortense/4d214a06baf608d4690703a8a216c6fc to your computer and use it in GitHub Desktop.
const BASE_URL = 'https://pokeapi.co/api/v2/pokemon/'
function fetchJSON(...args) {
return fetch(...args).then(response => response.json())
}
export async function fetchPokemonWithDetails() { // maybe pass the offset and limit as an argument
const results = await fetchJSON(BASE_URL)
.then(data => data.results)
const pokemon = await Promise.all(results.map(({url}) => fetchJSON(url)))
// console.log(pokemon)
return pokemon
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment