Ugo Lfe
Ugo Lfe

Reputation: 767

Problem extract data file json from Imgur API

I have a problem to extract a data from a json file created from a GET from Imgur API.

That is the 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 } ] },

I have no problem to extract the title data when I do this.props.post.title.

I tried : this.props.post.images.link -> TypeError: undefined is not an object (evaluating 'this.props.post.images.link')

this.props.post.images[0].link -> TypeError: undefined is not an object (evaluating 'this.props.post.images[0]')

Thanks for your time.

Upvotes: 0

Views: 126

Answers (1)

Ugo Lfe
Ugo Lfe

Reputation: 767

I found it. The correct way is to do this.props.post["images"][0].link

Upvotes: 1

Related Questions