Created
June 24, 2022 21:21
-
-
Save ortense/4d214a06baf608d4690703a8a216c6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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