javascript
客户端代码: function longConnect(){ var source = new EventSource('/contact/comet'); source.onmessage=function(event) { console.log(2); console.log(event.data); }; } 服务端代码 exports.comet = function(req, res, next){ res.set('Content-Type', 'text/event-stream'); setInterval(function(){ res.send("1"); },3000); };
报错:
http.js:690
throw new Error('Can\'t set headers after they are sent.');
不能重复设置 那express框架下该怎么做?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
已经知道为什么了
为什么呢,分享下