Hello all,
I am using Prismic with Express and Pug. I've been trying to render a rich text field which is a part of a slice (called content). I would like to take advantage of the prismic helpers (prismicH.toHTML()) but I'm running into an error when I use prismicH in the .pug file.
Cannot read properties of undefined (reading 'asHTML')
The field is a rich text field. Screenshot of the slice below:
Here's the .pug code.
each slice in document.data.body
if slice.slice_type == 'title'
h2.about__title=slice.primary.title_text
if slice.slice_type == 'content'
section.about__content
.about__contnet__wrapper
p.about__content__label=slice.primary.content_label
.about__content__details=prismicH.asHTML(slice.primary.content_details)
Here's the weird part. If I use prismicH.asHTML in express and console.log the result, I get the correct response.
Express.js /about Route:
app.get('/about', async (req, res) => {
const document = await client.getSingle('about')
document.data.body.forEach(section => {
console.log(section.primary)
if (section.slice_type == 'content'){
console.log(prismicH.asHTML(section.primary.content_details))
}
})
Express Response from code above
As you can see, the strong and em tags are applied when I console.log the result in express, but attempting to use the same syntax in pug results in the error above. Sorry if this is a newby question, I'm fairly new to front end development.
Any help is appreciated. I can send my repo or any additional information if needed. Thank you!