Query a Single Type Document

This page describes what you need to do to query a document for a custom type of the type Single. A Single custom type will contain only one document.

Before reading

This page assumes that you're using the Vue.js starter project or that you have setup your project as explained on the Integrating with existing project page.

With the Query Helper Function

In this example we are querying for the single instance of the custom type "navigation" using the query helper function.

Copy
this.$prismic.client.getSingle('navigation').then((document) => {
  // document contains the document content
});

Without the Helper Function

In the example above we are using a helper function but you can also do this by querying the document of the type "navigation" and selecting the first object in the results.

Copy
this.$prismic.client.query(
  this.$prismic.Predicates.at('document.type', 'navigation')
).then((response) => {
  const document = response.results[0]
  // document contains the document content
});

Querying by Language

Note that if you are trying to query a document that isn't in the master language of your repository this way, you will need to specify the language code or wildcard language value. You can read how to do this on theĀ Query by Language page.

If you are using the query helper function above, you do not need to do this.