Query by Tag in Javascript

This page gives you a couple of examples of how to query documents by their tags. If you want to query all of the documents with a certain tag, then you just need to specify the document.tags.

Example 1

Here is an example of a query of all the documents with the tag “English”.

Copy
//To retreive the API object check how to query the API
api.query(
    Prismic.Predicates.at("document.tags", ['English'])
).then(function(content) {
    // content is the response object, content.results holds the documents
});

Example 2

This example shows how to query all of the documents with either the tag "Tag 1" or "Tag 2" by using the any predicate.

Copy
//To retreive the API object check how to query the API
api.query(
    Prismic.Predicates.any('document.tags', ['Tag 1', 'Tag 2'])
).then(function(content) {
    // content is the response object, content.results holds the documents
});