JSON object changes when sent to server side?
Answered
Saltwater Crocodile posted this in #help-forum
Saltwater CrocodileOP
So I have an obj that looks like this when I log it from the client-side (in browser console):
But when I log it from the server-side (in terminal) it looks like this:
attrs becomes a function? What could be the problem?
{
"type": "doc",
"content": [
{
"type": "codeBlock",
"attrs": {
"language": "js"
},
"content": [
{
"type": "text",
"text": "function(){\nconsole.log('test');\n}"
}
]
}
]
}
But when I log it from the server-side (in terminal) it looks like this:
content: {
type: 'doc',
content: [
{
type: 'codeBlock',
attrs: [Function (anonymous)],
content: [
{
type: 'text',
text: "function(){\nconsole.log('test');\n}"
}
]
}
]
}
attrs becomes a function? What could be the problem?
Answered by joulev
try
structuredClone
'ing the tiptap document before sending to the server. either structuredClone
or JSON.parse(JSON.stringify(document))
2 Replies
try
structuredClone
'ing the tiptap document before sending to the server. either structuredClone
or JSON.parse(JSON.stringify(document))
Answer
Saltwater CrocodileOP
thanks, that solved the problem.