Hi,
I have two custom types: menu and page. I m trying to create a single query where i get all the menu items and one page item (by its uid). I wrote something like this but I get an empty array:
const query = await api.query([
Prismic.Predicates.at('my.page.uid', 'about-us'),
Prismic.Predicates.at('document.type', 'menu'),
]);
If I run only one of those Predicates then i get the correct content, but I don't seem to manage to have them both in one query only.
What am I doing wrong?
Thanks
Priyanka
(Priyanka Maheshwari)
July 28, 2021, 10:42am
3
Hello @carlomelisi
Welcome to the Prismic community, and thanks for reaching out to us.
The query you are doing is not correct to combine two different Custom Types. If you want to make a query by multiple types, it should look like that:
api.query(
Prismic.Predicates.any("document.type", ["article", "blog_post"])
)
Or another option is to make two different queries and combine the result, like:
const menuDoc = await api.getSingle('menu');
const pages = await api.query(
Prismic.Predicates.at('my.page.uid', 'about-us''),
I hope it is clear to you. Let me know if you have any doubts.
Thanks,
Priyanka
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
July 30, 2021, 3:03pm
4
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.