I have state data:[]
and I am trying to set the values of URL in the state:
componentDidMount(){
axios.get('http://localhost:8082/seekers')
.then( response => {
console.log(response.data);
this.setState({data: response.data})
})
.catch(error => {
console.log(error);
});
}
When I use a map to show the data:
this.state.data.map((dynamicData,key)=>
<div key={id++}>
{dynamicData.name}{dynamicData.bloodtype}{dynamicData.bloodunits}
</div>
)
I get this error:
TypeError: this.state.data.map is not a function
How to fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…