所以我调用了一个 API 并使用它来设置状态。
我的状态:
state = {
candlesticks: []
};
我的 API 调用和承诺函数:
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
});
});
}
我已经尝试了代码的不同变体,但它仍然给出了这个错误。我正在使用 Expo 框架。
undefined 不是一个函数(评估 'data.map(function (record){record.date *= 1000})')