微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

获取请求查询属性创建 404 错误

如何解决获取请求查询属性创建 404 错误

我在我的网站中使用 quill 富文本编辑器。在开发中,我可以自由地将我的内容写入数据库,但在我的实时生产环境中,如果我的 json 数组中的第一项没有以有效属性开头,它将导致 404 消息并且数据不会写入数据库.

示例:

[{"insert":" Fenton Fundamentals 个人套餐 \n每节 80 美元(1 小时一节)\n 3 节 200 美元(1 小时一节)\n*** 每增加一名运动员 10 美元 ***\ n"}]

https://website.com/edit/customfield?id=125&table=event&field=%5B%7B%22insert%22%3A%22Fenton%20Fundamentals%20Individual%20Package%C2%A0%5Cn%2480%20per%20a%20session%20(1%20hour%20session)%5Cn%24200%20for%203%20sessions%20(1%20hour%20session)%5Cn***%20%2410%20per%20an%20additional%20athlete%20***%5Cn%22%7D%5D

404(未找到)

但是如果我在第一行添加一个粗体属性,它将以完全相同的请求写入数据库

[{"attributes":{"bold":true},"insert":" Fenton Fundamentals 个人套餐"},{"insert":"\n$80 每次会话(1 小时会话)\n$200 3 节课(1 小时节课)\n*** 每增加一名运动员 10 美元 ***\n"}]

见下方代码

//编辑自定义字段

router.get('/edit/customfield',function(req,res){
    db[req.query.table].findOne({
        where:{id:req.query.id}
    }).then(item=>{
        item.update({customField:req.query.field}).then(e=>{res.json(e)})
    })
})


    

var editor = new quill('#editor',{
            modules: { toolbar: ['bold','italic','underline','strike','link',{ size: ['small',false,'large']},{'list': 'ordered'},{'list': 'bullet'},{'align': []}]},theme: 'sNow'
        });

        editor.setContents(JSON.parse(e.customField));
        

        $('#textEditor .save').on('click',function(){

            let delta = editor.getContents();

            console.log(JSON.stringify(delta.ops))

            $.get('/edit/customfield',{id:e.id,table:'event',field:JSON.stringify(delta.ops)}).then(function(s){
                
                e.customField = s.customField;
                $('#textEditor .error').addClass('alert-msg-green').html('update successful');
                
            })
        })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。