Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to access array of objects in javascript

const thumbnail = [
  {url: "https://randomUrlForImages.com"},
  {url: "https://randomUrlForImages2.com"}
]

I want to access url for displaying image
I’m using
<img src = {thumbnail.url} />
and its not working.
also tried using {thumbnail.0.url}
{thumbnail"[url]"}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When facing these issues try consoling the values you try to get…
Like here you can try

console.log(thumbnail[0].url)

or you can also use console.log(thumbnail[0]["url"])

if this works then you can delete the console logs and use it in the image code…

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading