0

I am new to Node.js

what is the use of req.end in Node.js .I use that but ,it print two times

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);
shyam
  • 9,134
  • 4
  • 29
  • 44
meda
  • 1
  • 1

1 Answers1

1
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);

In the above code when you hit localhost:3000/ from your browser, browser hit two requests at the same time one for favicon and one for '/ ' endpoint and you create only '/' router then all request will catch in '/' route. when you hit this endpoint from postman it will print one time in the console.

enter image description here