Json Error while updateing data in mongoose

问题描述 投票:0回答:0

在猫鼬中更新数据时出现此错误

SyntaxError: JSON 输入意外结束
在 JSON.parse ()
at parse

这是代码

exports.updateProduct = async(req, res, next) => { 让 product = await Product.findById(req.params.id);

if (!product) {
    return res.status(500).json({
        success: false,
        message: "Product not found"
    })

}

product = await Product.findByIdAndUpdate(req.params.id, req.body, {
    new: true,
    runValidators: true,
    useFindAndModify: false
});

res.status(200).json({
    success: true,
    product
})

}

期待答案

json parsing mongoose postman put
© www.soinside.com 2019 - 2024. All rights reserved.