I am trying to create in a separate function all the slices available on my site to retrieve them when needed. So far so good, but when trying to get the fields of the linked document fields, I get a [[PromiseResult]] and can't get the data. I am learning Prismic for a couple days only and so I am probably doing something wrong here, but since I can log the values correctly, I don't get what is wrong. I can console.log them but can't access them. Here is the part of the function I am talking about :
You need to use fetchLinks in your code. fetchLinks fetches a specific content field from a linked document. Find more detail here . This is in javascript but you can find documentation in the different frameworks as well.
You need to use fetchLinks in your code. 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.
Let me know if it doesn't work for you, we can work together to solve this.
Hi and thanks Priyanka for your kind return ! I already went on the link you shared with me, but the fields I am accessing are in a slice zone and the page you shared mentions that "It is not possible to retrieve the following content field types: Any field in a Group or Slice".
So I found the workaround below in order to access the data anyway to use them in my template and it works great but I wonder if it is ok for Prismic though.
@Priyanka, I might have not been precise in my answer but if there is a way to retrieve content field types in a slice group, it would be fantastic if you could share the way to get all this working. To be more precise on what I am trying to get : I am linking 4 articles on the homepage and the api only retrieve the id of the article, where I would need the title, excerpt, image...
Thanks !
@Priyanka I'm struggling to resolve some data with either fetchLinks or graphQuery.
I have a content type landingPage which has the key text field slug. In that content type I use a slice called TextBlock. This slice has a rich text field. In that field I've added a link to a different landingPage document.
I'm unable to resolve the slug field for the linked landingPage inside the slice's rich text field. Could you explain how it could be done?