I’m creating a simple app using React and Vite,I’m accesing PokeAPI to fetch the pokemon data and after that I’m just mapping those objects by leaving only the props I want.Sadly,when I want to use the bracket notation to access the object’s proprty like this:
image: pokemon.sprites.other["official-artwork"].front_default,
I get an error:
Uncaught (in promise) ReferenceError: artwork is not defined
and strangely,the code my browser is showing me looks like this:
image: pokemon.sprites.other.official - artwork.front_default,
full context:
pokemons = pokemons.map((pokemon) => ({
id: pokemon.id,
pokeName: pokemon.name,
image: pokemon.sprites.other["official-artwork"].front_default,
reactID: uuidv4(),
}));
Despite the errors I get the app is working.