0

I've tried to add more images in my sanity project without any result. I've add a schema for that.

{
  name: 'gallery',
  title: 'Gallery',
  type: 'array',
  of: [{ type: 'image', 
  options: {
    hotspot: true,
  },}]
 }

But when I console.log the result of the post where I upload more images I get only _ref and _type and no URL like in the mainImage.

How can I display multiple images? Thanks

Diego
  • 195
  • 2
  • 8

1 Answers1

2

to get the url you need to fetch data like that :

client.fetch(`*[_type == 'post']{
    _id,
    title,
    gallery[]{
        asset->{
            url
        }
    }]
}`)......
ran ia
  • 86
  • 1
  • 6