Strapi image not rendering in Astro framework

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I want to use an image in Astro, using strapi. I inserted the (i guess) the correct link according to the api. This is the code for the image, but it simply won’t display an image, and displays an error that says: Cannot read properties of undefined (reading ‘data’)

<Image
        src={`${import.meta.env.STRAPI_URL}${
            event.attributes.image.data.attributes.url
            }`}
      />

image.data is an array. Try:

event.attributes.image.data[0].attributes.url

Thank you SO much! i’ve been looking for it all day!

1 Like