本文介绍了node-express errror:express deprecated res.send(status):改用res.sendStatus(status)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过 response.send()
发送一个整数,但是我不断得到这个错误
I am trying to send an integer via response.send()
but I keep getting this error
express deprecated res.send(status): Use res.sendStatus(status) instead
我没有发送状态,我的代码是
I am not sending a Status, my code is
app.get('/runSyncTest' , function(request, response){
var nodes = request.query.nodes;
var edges = request.query.edges;
if (edges == "" ){
edges = []
}
userStory.userStory(nodes,edges);
connection.query('SELECT MAX(id) as id FROM report ', function(err,results, fields) {
idTest = results[0].id
response.send (idTest)
});
});
任何建议?
推荐答案
您可以尝试这样:
res.status(200).send((results[0].id).toString());
伙计是对的 - 它不允许数字。
Prooflink: http://expressjs.com/4x/api.html#res.send
Guys are right - it doesn't allow numbers.Prooflink: http://expressjs.com/4x/api.html#res.send
这篇关于node-express errror:express deprecated res.send(status):改用res.sendStatus(status)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!