Prismicio.getDocument()

Get a prismic document by id.

Usage

Hover over inputs/exits for more info.

var Prismicio = require('machinepack-prismicio');


// Get a prismic document by id.

Prismicio.getDocument({

apiEndpoint: 'https://mycompany.prismic.io/api',

accessToken: 'MC5WUWg4VFOHFh.77-9777-9Me-_73vv73vv70rUO-_vWPvv71O77-9ZUPvv73vv71pX--_vQdaNe-_vQ',

id: '1234',

slug: 'my-great-post',

ref: 'VUYf7y0AAJkBHcVj',

html: true,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Document found via id, but there is a new slug

newSlug: function () {

 

},

// Document not found

notFound: function () {

 

},

// Not authorized

notAuthorized: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

apiEndpoint required

Api endpoint for your prismic instance

'https://mycompany.prismic.io/api'
accessToken required

Token provided via settings/apps/.

'MC5WUWg4VFOHFh.77-9777-9Me-_73vv73vv70rUO-_vWPvv71O77-9ZUPvv73vv71pX--_vQdaNe-_vQ'
id required

Document id

'1234'
slug

Slug of document for given id.

'my-great-post'
ref

Control which versions of documents we can access. Defaults to master which is all live documents.

'VUYf7y0AAJkBHcVj'
html

Return document as html?

true

Exits

error

An unexpected error occurred.

newSlug

Document found via id, but there is a new slug

notFound

Document not found

notAuthorized

Not authorized

success

OK.