Query similar content via data boolean

Hi there,

In a blog post page, I am trying to query related blog posts based on a boolean (isFest) in my post content type. I wrote the following code, but it won't work, I have this error message instead 'SyntaxError: Unexpected token E in JSON at position 0'.

const relatedPosts = await Client.query( [Prismic.Predicates.at('my.blog_post.data.isFest', true)] )

Thanks for your help !

Hi Stephanie,

Welcome to the community!

I think the issue might be that your query should look like this:

const relatedPosts = await Client.query(Prismic.Predicates.at('my.blog_post.isFest', true))

The field must be in the top level of the document and not in a Slice.

Thanks.

Hi Phil,

Thanks a lot ! Indeed it works now like a charm ! Loving Prismic so far ! This is my first go with it and definitly worth learning :slight_smile:

Thanks again,
Stephanie

1 Like

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