Query a Single Type Document in Javascript

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.

In this example we are querying for the single instance of the custom type “navigation”.

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

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".

Copy
//To retreive the API object check how to query the API
api.query(
    Prismic.Predicates.at('document.type', 'navigation'),
).then(function(navContent) {
    // navContent.results[0] contains the document content
});