The problem is not that the state doesn't exist, it is that you are not using the correct context for state.
You need to bind
the axios callback function
, otherwise this
inside it will refer to its own context rather than that of the react component
axios.get(//url//)
.then( (response) => {
this.setState({data: response.data});
})
.catch( (error) => {
console.log(error);
})
and in render
render() {
return (
<ul>
{this.state.data.map(v => <li key={v.id}>{v.body}</li>)}
</ul>
)
};