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 Client object. If you want to learn how to do this, then refer to the How to Query the API page.
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.
const doc = await client.getSingle('navigation')
// doc 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" and selecting the first object in the results.
client.query(
Prismic.Predicates.at('document.type', 'navigation')
).then(function(response) {
var doc = response.results[0];
// doc contains the document content
});
Querying by Language
Note that if you are trying to query a document that isn't in the main 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.