How to get author's name and image of the blog post published

Hello gabrielszewh,

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.

So, if you have a custom type called “post” that includes a content-relationship field called which link to a custom type called “author,” your query will be:

await $prismic.api.query(
   $prismic.predicates.at('document.type','post'),
  { fetchLinks: ['author.name', 'author.image'] }
)

Let me know if you have any doubt.

Thanks,

Priyanka

3 Likes