【发布时间】:2020-10-16 10:09:03
【问题描述】:
我制作了 todo react 应用程序,其中用户单击删除按钮它会将删除请求获取到我的 node.js 服务器。
const deleteTodo = (id) => {
const q = `DELETE FROM todos WHERE id=${id}`;
connection.query(q, (err, results) => {
if (err) throw err;
console.log('delete', results)
})
}
但是,当我简单地使用下面的路由器选项时,
app.delete('/', function (req, res) {
(some function)
})
应用不会像这样删除。
另一方面,通过简单地制作它
app.delete('/todos/:id', function (req, res) {
(some function)
})
它将再次开始运行。
为什么会这样?
【问题讨论】:
标签: mysql node.js reactjs express