👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

How to Fetch the Reference Details in Preview.Prepare

1 replies
Last updated: Apr 16, 2020
Hey Guys how can I fetch the reference details in preview.prepare ?
          prepare(selection) {
            const { productRef } = selection
            return {
              title: 'Product',
              subtitle: productRef->name, // I want to display the name here 
            }
          },
Apr 16, 2020, 9:08 AM
You can access that in the
select
part of the preview, e.g.

select: {
  name: 'productRef.name'
}
Then use it in the prepare function
Apr 16, 2020, 9:53 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?