如何将 editorjs json 输出保存在数据库中并在节点应用程序的服务器端处理它?

问题描述 投票:0回答:1
saveButton.addEventListener('click',()=>{ 
    editor.save()
    .then((savedData)=>{          
 })

我正在尝试让单击按钮将数据提交到数据库。

javascript editorjs
1个回答
0
投票

数据库架构声明:

content: [
    {
      id: {
        type: String,
      },
      type: {
        type: String,
        required: true,
      },
      data: {
        type: mongoose.Schema.Types.Mixed,
        required: true,
      },
    },
    // { _id: false },
  ],

服务器:

content: JSON.parse(content)

客户:

const contentJSON = JSON.stringify(editorContent.blocks);
formData.append('content', contentJSON);

这对我有用

© www.soinside.com 2019 - 2024. All rights reserved.