Skip to content
Advertisement

Reactjs with Pokeapi

I have an app that searches the name of the pokemon reads the data eg. name, height, weight. Now when it comes to the abilities I can’t get the value of the name of the ability.

here’s my app.js

JavaScript

Advertisement

Answer

Abilities has this structure. You can check this by logging this.state.abilities

JavaScript

It’s just an array. What you need to do is iterate over this array to retrieve those name values. There are a lot of ways to do this but the general logic should be something like:

“For each of these objects in the abilities array, I need to retrieve ability.name”

I am going to post some code here but try to solve it yourself before looking at mine.

In your p tag, you can do this

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement