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.

With the query helper function

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

Copy
//To retrieve the API object check how to query the API
api.getSingle('navigation').then(function(document) {
    // document contains the document content
});

Without the query helper function

In this example, we show how to do the same thing without using the helper function. Here we are querying the document of the type "navigation".

Copy
//To retrieve the API object check how to query the API
api.query(
    Prismic.Predicates.at('document.type', 'navigation'),
).then(function(response) {
    // response.results[0] 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.