My problem is I get a list of data inside of my FetchData class buy its a list. I tried indexing the countries: data.Countries[0] for example 0 it gave me the values but I want all the data is there a way to do a foreach on this?
Fetch with index on countries: data.Countries[0]

Fetch without index on countries: data.Countries

fetchData.js
import React, { Component } from 'react';
import Countries from './countries';
class FetchData extends Component {
state = {
loading: true,
countries: null
};
async componentDidMount() {
const url = 'https://api.covid19api.com/summary';
const response = await fetch(url);
const data = await response.json();
this.setState({
countries: data.Countries,
loading: false
});
}
render() {
return (
<div>
{this.state.loading || !this.state.countries ? (
<div>loading</div>
) : (
<div>
<Countries WorldCountries={this.state.countries.Country} />
</div>
)}
</div>
);
}
}
export default FetchData;
countries.js
import React, { Component } from 'react';
const Countries = (prop) => {
return(
<h1>{prop.Countries}</h1>
);
}
export default Countries;