Trying to extract all text from an array of slices (doc.data.body)

I am trying to render my entire body (slices) as text. When I try this, the function returns an empty string. I have verified that the slices are present and have data in them.

Here is the code

import { RichText } from 'prismic-dom'

const slices = doc.data.body
const text = RichText.asText(slices)
console.log(text)
=> ''

Hello @jp1, welcome to the Community!

Could you give me more details about what you’re trying to do?

It is not possible to render the full content of an entire document response using a Rich Text method. This method is used to render, as its name implies, Rich Text fields.

I’m not sure if you want to see a preview of the API response, in which case a console.log alone should be enough to see the object. Or, if you want to display it in the browser, you could use dangerouslySetInnerHTML.

I look forward to your response.

This issue has been closed due to inactivity. Flag to reopen.