[英]Express doesnt send the end response
Im having nodeJS app with express 4.13.0 , when I run requests from postman the process has invoked but I dont get status successful (200)or any status , I see that the code was invoked (I got the console message) 我有一个具有express 4.13.0的 nodeJS应用,当我运行来自邮递员的请求时,该过程已被调用,但是我没有获得成功的状态(200)或任何状态,我看到代码被调用了(我收到了控制台消息)
console.log("Project replaced successfully ");
res.end("Replaced successfully ", 200);
I try even with just 我什至尝试
res.end(200)
and I still see that the postman is processing, what could be the reason? res.end(200)
,我仍然看到邮递员正在处理,这可能是什么原因?
According to the docs , res.end()
doesn't accept a status code and you should not use it if you send back data, use res.send()
instead. 根据文档 ,
res.end()
不接受状态码,如果您发送回数据,则不应使用它,而应使用res.send()
。 By default, the status code is 200, if you need a different one, write something like this res.status(404).send('hello')
. 默认情况下,状态代码为200,如果您需要其他代码,请编写类似以下
res.status(404).send('hello')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.