So I make a call to a API and use it to setState.
My state:
state = {
candlesticks: []
};
My API call and promise function:
componentDidMount() {
axios
.get(
"apiurl"
)
.then(data => {
let mappedData = data.map((record) => {record.date *= 1000}); //getting the error here with the map()function
this.setState({
candlesticks: mappedData
});
});
}
I've tried different variations on the code but it still gives this error. I'm using Expo framework.
undefined is not a function (evaluating 'data.map(function (record){record.date *= 1000})')
datafrom the response. That could be something likedata.body.mapordata.content.map. Printdatato see what it really contains!