node-express错误:表达已弃用的res.send(status):使用res.sendStatus(status)代替 [英] node-express error : express deprecated res.send(status): Use res.sendStatus(status) instead

查看:1647
本文介绍了node-express错误:表达已弃用的res.send(status):使用res.sendStatus(status)代替的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过response.send()发送一个整数,但是我一直收到此错误

I am trying to send an integer via response.send() but I keep getting this error

表达已弃用的res.send(status):改为使用res.sendStatus(status)

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());

人是正确的-不允许输入数字. 证明链接: 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错误:表达已弃用的res.send(status):使用res.sendStatus(status)代替的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆