首页 > 解决方案 > PUT 请求不运行更新

问题描述

我是节点 js 的新手,我正在努力处理 PUT 请求,由于某种原因它不会在我的数据库中更新。请帮忙,谢谢。

app.put('/orders/:id', (req, res) => {
    pool.getConnection((err, connection) => {
        if(err) throw err
        console.log(`Connected as id ${connection.threadId}`)

        const {orderID} = req.body
        const {status} = req.body

        connection.query('UPDATE orders SET status = "Complete" WHERE orderID = ?', [status, orderID],
        (err, rows) => {
            connection.release()

            if(!err) {
                res.send(`Order ${orderID} has been updated`)
            }
            else {
                console.log(err)
            }
        })
    })
})

标签: node.jspostman

解决方案


推荐阅读