Look at the API response:
{
"id": 233383,
"date": "2019-10-28T10:50:53",
"date_gmt": "2019-10-28T10:50:53",
"modified": "2019-10-28T10:55:14",
"modified_gmt": "2019-10-28T10:55:14",
"link": "https://www.stylist.co.uk/long-reads/friendship-friends-whatsapp-facebook-messenger-social-media-group-chat-best-friends-psychology-advice/233383",
"title": {
"rendered": "Whatsapp and Facebook Messenger: how group chat is changing the dynamic of our friendships"
},
"slug": "whatsapp-and-facebook-messenger-how-group-chat-is-changing-the-dynamic-of-our-friendships",
etc.
It does not have a .data
property, so
.then(data => {
this.setState({
apiData: data.data
})
})
sets undefined
to this.state.apiData
.
The only rendered
exists in the one top-level object in the response, so you should remove the .map
entirely, something like:
.then(data => {
this.setState({
apiData: data
})
})
<h1>hello something</h1></center>
{this.state.apiData.title.rendered}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…