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've already imported the Prismic library and retrieved the api object. If you want to learn how to do this, then refer to the How to Query the API page.

With the Query Helper

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

Copy
api.getSingle('navigation').then(function(document) {
    // document contains the document content
});

Without the Helper Function

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

Copy
api.query(
    Prismic.Predicates.at('document.type', 'navigation')
).then(function(response) {
    var 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.