node.js - 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)
}
})
})
})
解决方案
推荐阅读
- c - 如何在同一台机器上以编程方式获取通过 AF_INET 套接字连接到我的代理的进程的 PID?
- codeigniter - 通过辅助函数在 codeigniter 中初始化第二个数据库
- javascript - create-react-app 中的 Google Calendar API gapi.client.init 抛出错误
- maven - Artifactory:上传的工件不再有 md5 和 sha1 文件
- python - 如何在python中保存相对于其id的坐标值
- android - Android 应用程序或其内容在 Google Pixel 2 上被截断
- mongoose - 猫鼬填充嵌套对象内部
- excel - SumIf 不同的标准
- java - 如何使用带有 JarSigner 的 XMSS (PQC) 签名方案对 .jar 文件进行签名
- rstudio - 在我的数据中处理额外的“+AC0”