Fetchlinks when query documents by type

Hey All,

I hope you are well.

Anyone know how to fetch links when querying multiple documents.

await $prismic.api.query(
$prismic.predicates.at(‘document.type’, ‘product’),
fetchLinks: [‘product_types.type_title’]

I can’t get this to work.

I hope someone can help.

Many thanks,

I have also tried with { fetchLinks: [ ‘my.product_types.type_title’ ] }

Hey Kristian,

Thanks for posting! I can’t see any obvious problems with your code, so I could suggest some troubleshooting.

In your fetchLinks array, the value should be:

  • First, the API ID of the custom type referenced in your content relationship field.
  • Then, the API ID of the field that you want to retrieve on that custom type.

So, if you have a custom type called “post” that includes a field called “author” with a link to a custom type called “person,” your query could look like:

await $prismic.api.query(
  { fetchLinks: ['person.name'] }

If that doesn’t help, could you send me the response that you’re getting from the API, and tell me the name of the repo you’re querying?


Thanks for you reply. Seems to be working now. Don’t know what I did wrong before.

Thanks again.

That’s great to hear! Please let me know if you have any other questions :slight_smile: