【发布时间】:2021-08-21 16:56:29
【问题描述】:
我目前正在 Plesk Web 服务器上运行 API,配置并运行 Node.js。我的 post 请求和 get 请求似乎可以正常工作并完美返回,但是当我尝试发送 put 请求时,我被告知“从应用程序收到不完整的响应”。
在查看了几个线程后,我发现这可能与“secret_key”的问题有关,但这让我感到困惑,为什么这只会发生在 put 请求上,以及如何纠正无法访问控制台的问题。
put请求的代码如下:
app.put('/players', function (req, res) {
connection.query('UPDATE `players` SET `playerID`=?,`money`=?,`bounty`=?', [req.body.playerID ,req.body.money, req.body.bounty], function (error, results, fields) {
if (error) throw error;
res.end(JSON.stringify(results));
});
});
例如,在发送请求时,我会发送以下正文:
{"playerID":53,"money":2332,"bounty":4}
作为将返回该错误的 JSON。
感谢您的帮助。
【问题讨论】: