Query by Tag
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.
Copy
this.$prismic.client.query(
this.$prismic.Predicates.at('document.tags', ['Featured'])
).then((response) => {
// response is the response object, response.results holds the documents
});
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
this.$prismic.client.query(
this.$prismic.Predicates.any('document.tags', ['Tag 1', 'Tag 2'])
).then((response) => {
// response is the response object, response.results holds the documents
});
When you query the api endpoint of your repository, you can receive many different properties from the repository such as the ref, Custom Types, languages, tags, etc.
To receive all the the tags from the API data, simply query the API as shown here.
Copy
const apiEndpoint = "http://your-repo-name.prismic.io/api/v2";
this.$prismic.api(apiEndpoint).then((result) => {
const tags = result.tags;
console.log(tags);
});