Querying Prismic Content

Understand the API Response

Transcript

[00:00] The API response for your single page query is returned as a JSON object. Within that object, you have technical data about the page on the top level, such as the ID, the first and latest publication dates and alternate languages of the page.

[00:14] All the author generated content is found inside the data object. You can see the contents of this by running console.log(page.data) Make sure to refresh your page to see this in your terminal. At the top level of this object, you'll see the contents of the Static Zone, so your SEO content, et cetera.

[00:32] Then within the data object, you'll find your slices array at data.slices, so you can see the contents of this in your terminal by running console.log(page. data.slices).

[00:42] Each Slice is contained within its own JSON object. The order of the slices array is defined in the Prismic editor by your content authors. So this means Mr. McDonald decides which Slice is output where on your page.

Practice Activity

  • Run console.log(page) to see your page's technical data
  • Run console.log(page.data) to see your Static Zone and SEO data
  • Run console.log(page.data.slices) to see your Slices

Answer to continue

Quiz banner

The content of the Static Zone is returned…?

Slices are returned together….?

Each Slice is returned….?