Node Error : Cannot set headers after they are sent to the client
2020-02-02 16:13
1301 查看
Node Error : Cannot set headers after they are sent to the client
问题原因
在请求时 ,才会出现这种报错,一定是因为,浏览器请求一次之后,服务器后台返回了两次或以上的响应
解决办法
清理多余次数响应;每次响应后立马return掉函数
router.get('/',function(req,res,next){ Goods.find({},function(err,doc){ if(err){ res.json({ status:'1', msg:err.message }); }else{ res.json({ status:'0', msg:'', result:{ count:doc.length, list:doc } }) } }) })
- 点赞 1
- 收藏
- 分享
- 文章举报
相关文章推荐
- Node Error : Cannot set headers after they are sent to the client
- Error: Can't set headers after they are sent to the client
- Cloud 9 IDE 出现“Can\'t render headers after they are sent to the client”错误的临时解决方案
- 【Express】解决Error: Can't set headers after they are sent.
- node "Can't set headers after they are sent"
- Express: Can’t set headers after they are sent.
- [Nodejs] 记录一个小坑:Can't set headers after they are sent
- Can't set headers after they are sent
- Node.js Error: Can't set headers after they are sent
- can't set headers after they are sent
- 关于Can't set headers after they are sent.问题原理详解
- Error: Can't set headers after they are sent错误之坑
- 解决Express 的 Error: Can't set headers after they are sent.
- Can't set headers after they are sent
- express报错之——Error: Can't set headers after they are sent.
- Can't set headers after they are sent
- After logging in to the Lotus Notes Client, you are prompted for a password in DOS-like window (Viru
- CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
- Unable to connect to data source (DSN: shangjihuiclient; Network Address: ; Port Number: 53397). Cannot connect to TimesTen Server. Verify that the TimesTen Server is running or verify that your TCP PORT is set correctly.
- 异常System.Web.HttpException (0x80004005): Server cannot set status after HTTP headers have been sent.