从Imgur API的GET创建的json文件中提取数据时遇到问题。
那是json:
{
"id": "ADgvagy",
"title": "This game is so much fun ",
...
"include_album_ads": false,
"images": [
{
"id": "VLeeDfj",
...
"in_gallery": false,
"link": "https://i.imgur.com/VLeeDfj.mp4",
"mp4_size": 2707912,
"mp4": "https://i.imgur.com/VLeeDfj.mp4",
"gifv": "https://i.imgur.com/VLeeDfj.gifv",
"hls": "https://i.imgur.com/VLeeDfj.m3u8",
"processing": {
"status": "completed"
},
"comment_count": null,
...
"score": null
}
]
},
当我执行 this.props.post.title 时,我可以轻松提取 title 数据
我尝试过: this.props.post.images.link -> TypeError:未定义不是对象(正在评估“ this.props.post.images.link”)
this.props.post.images [0] .link -> TypeError:未定义不是对象(正在评估'this.props.post.images [0 ]')
感谢您的时间。
答案 0 :(得分:1)
我找到了。正确的方法是进行this.props.post["images"][0].link