這裏是我的代碼,我沒有得到如何在頁面上顯示數據。當我試圖給我的頁面上也沒有,它表明:如何獲取API數據並在react.js中的表格中顯示
警告:數組或迭代每個孩子都應該有一個獨特的「鑰匙」 道具。
這是我的代碼。
import React, { Component } from 'react';
import './App.css';
class App extends Component {
constructor(){
super();
this.state = {
data: []
}
}
componentDidMount()
{
fetch("https://blockchain.info/ticker").
then((Response) => Response.json()).
then ((findresponse)=>
{
console.log(findresponse)
this.setState({
data: [findresponse]
});
})
}
render()
{
return(
<div>
{
this.state.data.map((dynamicData, Key) =>
<div>
<span>{dynamicData.key}</span>
</div>
)
}
</div>
)
}
}
export default App;
findresponse是怎麼樣的?你需要括號嗎數據:[findresponse]'? – Walk