Query a Single Type Document

This is used to retrieve the document for a custom type of type Single.

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

Copy
      api.getSingle('navigation').then(function(navContent) {
    // navContent contains the document content
});
    
Copy
      $navContent = $api->getSingle('navigation');
// $navContent contains the document content
    
Copy
      nav_content = api.getSingle("navigation")
# nav_content 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
      api.query(
    Prismic.Predicates.at('document.type', 'navigation'),
).then(function(navContent) {
    // navContent.results[0] contains the document content
});
    
Copy
      $navContent = $api->query(Predicates::at('document.type', 'navigation'));
// $navContent->getResults()[0] contains the document content
    
Copy
      nav_content = api.query(Prismic::Predicates.at("document.type", "navigation"))
# content.results[0] contains the document content