My index.js file looks like this
var http = require('http');
var url = require('url');
var server = http.createServer(function (req, res) {
var parseUrl = url.parse(req.url, true);
var path = parseUrl.pathname;
var parsedurl = url.parse(req.url, true);
// Get the path
var path = parsedurl.pathname;
var trimmedPath = path.replace(/^\/\/+$/, '');
var queryStringObject = parsedurl.query;
// Get the HTTP Method
var method = req.method.toLowerCase();
// Send the response
res.end('Hello World\n');
// Log the request path
console.log(
'Request received on path:' +
trimmedPath +
'with method' +
method +
'query' +
queryStringObject
);
});
server.listen(5000, function () {
console.log(`Server is listening kamal`);
});
My terminal Error screenshot I don't know why I am facing this error, to the best of my knowledge the code looks correct ?