Hey @rizqinizamil,
Welcome to the Prismic community, and thanks for posting this question!
To fetch content relationships, you can use the fetchLinks
option:
To use fetchLinks
, add an options
object to your query, with a fetchLinks
key. For the fetchLinks
key, set the value to [custom-type-of-linked-document].[field-on-linked-document]
.
When you include the fetchLinks
option, the API will fetch the field on every linked custom type in your document, including in the repeatable zone of the slice. So, if you have a FeaturedPosts
slice, which displays a curated list of posts. In the repeatable zone for the slice, you have a content relationship that links to a post
custom type. In Next.js, you need the title for every post in that slice.
For instance, if you are building a "homepage" document, your query might look like this:
const document = await client.getSingle('homepage',
{'fetchLinks': 'author.name'}
)
The API should return your document, and in the FeaturedPosts
slice there will be data
keys with each post title.
Please let me know if I correctly understood your question, and if this answer works for you! If not, let me know and we'll keep working on it together
Sam