I am new to node.js and learning from tutorials online. I was trying out the following piece of code :
var http = require("http");
// create a server
http.createServer(function(req, res) {
console.log("Received Request");
res.writeHead(200, {'Content-Type':'application/json'});
res.end("{'status':'200', 'message':'Hello World'}");
console.log("Response Sent");
}).listen(process.env.PORT, process.env.IP);
I did receive the correct response but in console the output was :
Received Request
Response Sent
Received Request
Response Sent
I wanted to know why was my code running twice ?? Am I making some mistake ? Please help !!