Get Images with ReactJS

Hi @tdammy. Thanks for the code solution for this question.

One caveat, as mentioned by @maggie0002 above, is that sometimes the formats for certain images might not exist so it can be good to enclose the rendering of an element in a conditional expression so that it doesn’t try to render if that format doesn’t exist. Like so with your example:

{data && data.img[0].formats.thumbnail && <img src={ApiUrl + data.img[0].formats.thumbnail.url} alt={data.title} />

Hope that helps!

-Rm