Fetching more than 2 documents api.query doesn't work

Hi all!

I want to fetch more than 2 documents based on a tag. See the docs: @prismicio/client Technical Reference - Prismic . It doesn't seem to work. I get a successful response, however without any results (just an empty array).

See my code below.
Note: If I try to use only two Prismic.Predicates.at() it works properly for every tag/type.

Thanks for your help!

export const prismicFetch = (predicates, options) => {
  return Prismic.getApi(envConfig.PRISMIC_API_URL, {
accessToken: envConfig.PRISMIC_API_TOKEN
  }).then(api => {
return api.query(predicates && predicates.length ? predicates : '', {
  lang: envConfig.PRISMIC_LANGUAGE,
  pageSize: 200,
  ...options
});
  });
};

export const fetchFeed = () => {
  return prismicFetch(
[
  Prismic.Predicates.at('document.type', 'generic_content'),
  Prismic.Predicates.at('document.tags', ['male']),
  Prismic.Predicates.at('document.tags', ['feed-discover'])
]
  );
};

Hi @barbara.rekowska, at first look the code here seems good, so I’m not sure why this might be happening.

Are you sure that you have any documents of the “generic_content” type with both the “male” and “feed-discover” tags?

Can you share the url for your Prismic repo with me? If you don’t want to share it publicly, you can send it to me in a direct message.

@Levi

I thought the predicates indicated to 'OR' statement, so that I can fetch all generic_content documents and all docs with 'male' tag.
Now it all makes sense why it didn't work. Thanks!

@barbara.rekowska Yeah, that’s the issue here. The predicates all stack as ‘AND’ operators.

But you can accomplish what you are trying to do by using the any predicate for your tags. You can learn more about it here:
https://prismic.io/docs/javascript/query-the-api/query-predicates-reference#28_0-any

This issue has been closed due to inactivity.