如何使用Express / Node以编程方式发送404响应? [英] How to programmatically send a 404 response with Express/Node?
本文介绍了如何使用Express / Node以编程方式发送404响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
现在有一个专门的 状态
功能在响应对象上。
res.status (404)// HTTP status 404:NotFound
.send('Not found');
I want to simulate a 404 error on my Express/Node server. How can I do that?
解决方案
Nowadays there's a dedicated status
function for this on the response object. Just chain it in somewhere before you call send
.
res.status(404) // HTTP status 404: NotFound
.send('Not found');
这篇关于如何使用Express / Node以编程方式发送404响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文