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.io – build remarkable experiences at scale

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

Categorized in