Rest API as HTML

I am using the Rest API to add content to my project. Is there a way of getting the actual HTML in the response from Prismic. Prismic gives a JSON response something like this.

image

At the moment I am looping through the data, adding the type names as a class name in of a , and creating styles to mimic those types. For example {Text} could produce blah blah blah .

Hi Ken,

Welcome to the community :grinning:

You can easily convert the JSON output using the Prismic DOM. It’s our JS library for doing exactly that.

Here’s an example of how to use it in pure JS:

var PrismicDOM = require('prismic-dom');
var titleHtml = PrismicDOM.RichText.asHtml(document.data.title, linkResolver)

You can see more examples here, we also have examples in many different frameworks:
https://prismic.io/docs/javascript/templating/rich-text#1_0-output-as-html

Let me know if you have any other questions.

Thanks.

This issue has been closed due to inactivity.