Contentful logo

Contentful Community

Delivery Api giving out Raw data instead of Json for the RichText editor

The Rich text editor in the content model should actually give out data to the api in a json format but the data i am receving is in raw form i tried making a new content model tried adding two rich text field but none the above worked for me
ps: I am trying to make a blog post content model
Below in the Picture the body is the Name of the richtext editor field:

Hi @jay90194,
To represent Rich Text correctly, you need a renderer:

I tried using npm package of contentful to react component render but for that the data passed through api should have Json format but the data i am receiving is in raw format.

1 Like

I am facing the same issue and I could not render with raw type

Hey, Did you find any solution for this ? I am currently using Markdown editor in contentful Which is not the best compared to the rich text editor.

I was having trouble with this until I figured out that I could just put the raw data into JSON.parse() before passing that all into documentToReactComponents()

In the end, it looked like

{documentToReactComponents(
JSON.parse(props.data.contentfulBlogPost.body.raw)
)}

After that, my webpage ended up loading all my body content, yey

7 Likes

I came up with the same solution as above to use JSON.parse(). This worked great for everything except for embedded assets. I cant figure out how to access the nodes for images, would be much easier to figure out why the query is returning raw instead of json in the first place.

2 Likes

im also facing the same issue. How do I fix this. Target.Fields is not available in embedded-asset-block

1 Like

Me too.

I am trying to get my Gatsby blog off the ground and I am currently having this issue. Running http://localhost:8000/___graphql I only have the option for Raw.

I understand I also need the Rich Text renderer that’s fine, but I need JSON to work in the query and that’s just not happening…

@kevinbellock: you are spot on — need to get that JSON!

Really don’t want to go down the JSON.parse() road as it looks like that’s not ideal based on Kevin’s experience.

Anybody?