当使用req.end它打印在控制台两次。为什么?
我是新来的Node.js
什么是Node.js的。我使用req.end
的使用,但它打印两次
app.use('/',function(req,res){
res.send("hello world"); //send to browser
console.log("by"); //print in console
req.end; //req is end here
}).listen(3000);
回答如下:
app.use('/',function(req,res){
res.send("hello world"); //send to browser
console.log("by"); //print in console
req.end; //req is end here
}).listen(3000);
在当你打本地主机上面的代码:3000 /从你的浏览器,浏览器打在同一时间一个图标两个请求,一个用于“/”端点与您共创只有“/”路由器,那么所有的请求将赶上“/”路线。当你打从邮递员该端点会在控制台打印一次。