Trouble getting fetchLinks results

I’m having some difficulty with linked documents, that I thought should be pretty straight forward. I have the following code:

const api = await Prismic.getApi('');
const response = await api.getSingle('resources_landing',  {'fetchLinks' : ['']});

The response I get back has all of resources_landing including its many document link fields, but the linked_documents array is empty.

I’m on prismic-javascript 2.7.1. It seems like the documentation is pushing me towards GraphQL, which may be a little verbose for this. Is fetchLinks being depreciated?

Hi @perry, welcome to the Prismic community!

There is no plan to deprecate fetchLinks, it should be working just fine. What is deprecated is the linked_documents array.

Rather than looking for the fetched content in linked_documents, you should dig into the data and find your links in the actual content fields of your resources_landing document.

Let me know if you’re able to find it there.

Ah, this was it. Thank you!

1 Like