Unable to encode .... of type object - Prismic.Predicate.at()
See original GitHub issueHello,
I’ve tried to use multiple predicates on a query as the example but when the code (see below) is executed I got an error: Unable to encode no-case-study of type object
const noCasesStudiesProjects = client().then(api => {
return api
.query([
Prismic.Predicates.at('document.type', 'project'),
Prismic.Predicates.at('document.tags', ['no-case-study'])
])
.then(data => {
return data.results;
});
});
I’m using : Nuxt 2.0.0 and prismic-javascript ^2.0.1
Any ideas ? Thanks
NB : Until yesterday, everything worked well 😕 NB2 : Seems to works in build and generate (nuxt) process 🧐
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Unable to encode .... of type object - Prismic.Predicate.at() #77
Hello, I've tried to use multiple predicates on a query as the example but when the code (see below) is executed I got...
Read more >Rest API Technical Reference - Documentation - Prismic
The query parameter (q) accepts a set of predicates (encoded as a URI component) as its value. Each predicate is enclosed in square...
Read more >prismicio/client Technical Reference - Documentation - Prismic
Accepts a Custom Type API ID as a string, an array of document UID strings, and an optional params object. Queries your Prismic...
Read more >Possible bug in PHP Predicates::at('document.type'
I have just started getting this error: regardless of which "page" number I set, the results are always from the first page!
Read more >OR in Prismic predicate to return documents with two differen ...
Hello. I need to pull two different document types in the same query (preferably). For example: this.$prismic.api.query([ this.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay got a non-minified version of prismic-javascript library so i could debug it, looks like this comes down to this line: https://github.com/prismicio/prismic-javascript/blob/edd2c5b66926492dfabd0371100d9f2bc6b413c4/src/Predicates.ts#L41
Due to some awesome javascript idiosyncrasies, which may be dependent on the version of Node being used, instanceof won’t work here. Dropped in some logging, hope you find it as fascinating as I do 😛
Can we switch to use one of the last two methods to test if its an array? Both fix the issue. @arnaudlewis ?
Thank you so much @mcrider for finding a workaround.