I am currently studying react native and I explore the process of rendering the api data in the list view. Right now I have already the api data however when I tried mapping the array it says.
TypeError: this.state.readings.map is not a function. (In 'this.state.readings.map(function (value) { return console.log(value); })', 'this.state.readings.map' is undefined)
Here is the sample api:
Inside of my ComponentDidMount:
componentDidMount() {
fetch('http://myip:3000/api/readings/3')
.then(response => response.json())
.then(data => this.setState({readings:JSON.stringify(data)}))
}
My State:
this.state = {
readings:[],
}
My Render:
render() {
console.log(this.state.readings);
return (
{
this.state.readings.map(value => {
return (
console.log(value)
)
})
}
)
}
