Hi there,
Currently I'm implementing Prismic queries intro my Next.js project and have this query:
const maintenance = await client.query(
Prismic.Predicates.at("my.service.uid", ["test1", "test2"]),
Prismic.Predicates.at("my.service.status", "maintenance")
);
I want to query the documents "test1" and "test2" of the type "service" but only if the value of the select field "status" is equal to "maintenance".
When I'm executing the query from above, I'm getting this error in the console:
Error: Unknown field 0
Where is the problem here?
Hey @feicht.marco ,
I'm not sure what exactly is causing your Error: Unknown field 0
, but I can see a problem in your code. The at
predicate does not accept an array. It only accepts a single value (except for document tags). You could try using the any
predicate:
any("my.service.uid", ["test1", "test2"])
Let me know if that helps.
For more detail, check our the Predicate reference:
The Prismic Rest API is an extremely fast, flexible, and powerful engine for your content. On this page, you will learn how to query the Rest API, including how to use Predicates, query options, and GraphQuery.
Sam
Hi @samlittlefair ,
I'm getting the error always when I combine two Predicates. Like in the example above.
Priyanka
(Priyanka Maheshwari)
June 28, 2021, 9:16am
7
Hello @feicht.marco
My colleague Sam is on vacation, I am Priyanka from the Education team who assist you with your query.
I can see one more issue in your code. You need to combine the multiple predicates in an array like this:
const maintenance = await client.query( [
Prismic.Predicates.at("my.service.uid", "test1"),
Prismic.Predicates.at("my.service.status", "maintenance")
] );
Give this a try and let me know.
Thanks,
Priyanka
1 Like
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
July 6, 2021, 12:15pm
8
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.