小编Ray*_*d17的帖子

TypeError:在 Node js 中通过 SQL 查询提供时,参数回调必须是函数

这是代码:

\n\n
 application.post(\'/Modification/SaveEdit/:idd\',function(req,res){\n var mem = req.body.memo;\n\n connection.query(\'UPDATE memos SET textMemo = ?\',mem,\'WHERE idMemo = ?\',req.params.idd, function (error, results, fields){\n        if (error) {\n    console.log("error ocurred",error);\n    res.send({\n      "code":400,\n      "failed":"erreur survenue"\n    })\n  }else{\n    console.log(\'Resultats: \', results);\n    res.send({\n      "code":200,\n      "success":"votre memo est bien modifi\xc3\xa9 ! "\n        });\n  }\n  });\n\n\n\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我认为这是我的查询的语法,但我不知道如何正确编写它。

\n\n

这是错误:

\n\n
TypeError: argument callback must be a function when provided\nat Function.createQuery (/home/mohand/node_modules/mysql/lib/Connection.js:57:13)\nat Connection.query (/home/mohand/node_modules/mysql/lib/Connection.js:181:26)\nat /home/mohand/TpsWEB/DMajour/expreServer.js:146:13\nat Layer.handle [as handle_request] (/home/mohand/node_modules/express/lib/router/layer.js:95:5)\nat next (/home/mohand/node_modules/express/lib/router/route.js:137:13)\nat Route.dispatch (/home/mohand/node_modules/express/lib/router/route.js:112:3)\nat Layer.handle [as handle_request] (/home/mohand/node_modules/express/lib/router/layer.js:95:5)\nat /home/mohand/node_modules/express/lib/router/index.js:281:22\nat param (/home/mohand/node_modules/express/lib/router/index.js:354:14)\nat …
Run Code Online (Sandbox Code Playgroud)

mysql node.js express

1
推荐指数
1
解决办法
7771
查看次数

标签 统计

express ×1

mysql ×1

node.js ×1