Resolving references in preview content on site

4 replies
Last updated: Jun 8, 2020
One more question! I have a preview thingie based on this: Now I want to consult a field on a reference (e.g.>nestedPoperty
), but the object passed in just contains the reference. How can I resolve the reference in this context?
May 11, 2020, 8:22 PM
I think you will need to query that data async, using the client.
something along the lines of:

import client from 'part:@sanity/base/client'

export default async function resolveProductionUrl(document) {

  const referencedDoc = await client.getDocument( ref)

  return `<${}>`
May 11, 2020, 8:30 PM
Perfect, thanks again!
May 11, 2020, 9:03 PM
Perfect, thanks again!
May 11, 2020, 9:03 PM
Does this actually work? and sanity ticket 827
Jun 8, 2020, 9:27 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?