Hello!!
Im trying to access JSON data through an API and display the data in a table. I’ve successfully displayed the data from the JSON object, but cant seem to access the data in the nested object. If i could get any help that would be greatly appreciated!
heres the code!
class CoinList extends Component {
constructor(props) {
super(props);
this.state = {
coinData: [],
}
}
componentDidMount() {
fetch('https://api.nomics.com/v1/currencies/ticker?key=' + apiKey +"&interval=1d")
.then(response => response.json())
.then(data => this.setState({ coinData: data }))
.catch(error => {console.error(error)})
}
render() {
return (
<div className="Table-container">
<table>
<thead>
<tr>
<th> h1 </th>
<th> h2 </th>
</tr>
</thead>
<tbody>
{this.state.coinData.map((coin) =>
<tr key={coin.id}>
<td> {coin.currency} </td>
<td> {coin.rank} </td>
</tr>
)}
</tbody>
</table>
</div>
)
}
}
and here is the JSON data