Error: Unknown field 0

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:

Sam

Hi @samlittlefair ,

I'm getting the error always when I combine two Predicates. Like in the example above.

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

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