Querying content relationship within a Slice repeatable zone using Prismic API

We are using the Prismic API to query our data through javascript. When querying a page we are retrieving slices from the body, in some slices there are content relationships within the slice repeatable zone but this only returns the id of the custom type the slice is linked to. Is there a way from retrieving all the data from the linked custom type without having to query the ID separately.

Query for context - client.query(Prismic.Predicates.at("my.product_page.uid", "test-product"))

1 Like

Hello Ian,

Thanks for reaching out to us.

In this case, you need to add fetchLinks option to get the required fields from the linked custom_type. The fetchLinks option allows you to retrieve a specific content field from a linked document and add it to the document response object.

Here is an example:

const doc = await client.getByUID('post', uid, {'fetchLinks': 'author.author.name'});

You will find more detail here.

Let me know if you have any doubt.

Thanks,
Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.