I've been playing around with the pokeAPI and I've made a AJAX call to the api. When I call the api everything works and I can navigate to the value I want. However whenever there is an array that I'm trying to get a value form it returns with this error.
This happens when I try to go through an array and nothing else. This is what I used to call the api.
fetch('http://pokeapi.salestock.net/api/v2/pokemon-species/' + this.state.pokemonValue + '/')
.then(results => {
return results.json();
}).then(data => {
this.setState({pokemonData: data});
});
This is the array I'm trying to access in the api.
I get to this array with which brings me to an array of objects called "names"
The JSON file that I'm accessing is this
http://pokeapi.salestock.net/api/v2/pokemon-species/2/
const pokemon = this.state.pokemonData;
console.log(pokemon.names);
However when I try to get to one of the array items its gives the error...
console.log(pokemon.names[1]); // === ERROR


pokemon.names? No such thing. You wantpokemon[0].name...