Querying by a field throws 400 error

Hello Everyone,

I'm currently trying to get familiar with Prismic's predicate system. I'm building an ecommerce site and I'd really like to have a 'Related products' wrapper. Perhaps the most logical (although let me know if I get this wrong) solution to this would be to grab the category of the product and query and render the products that have the same category. Unfortunately, it always leads to a 400 error and I'm not sure what I'm getting wrong here. Could someone help me figure out the root of the problem?

This is what my code looks like:
const Client = Prismic.client(apiEndpoint, {accessToken})

export default function SimilarProducts(props) {
const [content, setContentInfo] = useState(0)
useEffect(async () => {
const response = await Client.query([
Prismic.Predicates.at('my.product_info.category', 'Fülbevalók')
]
);
setContentInfo(response)
}, )

And this is what a product looks like:

Thank you for your help in advance!

Hello Sigalizer,

Welcome to the Prismic Forum.

I'm assuming that you have a custom_type with the API id as product_info. In this, you have a key text field name as a category. While looking at your API response, the category value is "Fülbevaló," not 'Fülbevalók'. So your query should be like:

Prismic.Predicates.at('my.product_info.category', 'Fülbevaló')

Give this a try and let me know.

Thanks,

Priyanka

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