Reputation: 2008
I am running the following code snippet from the node js beginner book.
var http = require("http");
var url = require("url");
function onRequest(request, response) {
console.log("request url issss " + request.url);
var pathName = url.parse(request.url).pathName;
console.log("Request for " + pathName + " received");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello Worldd");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started11.");
Now while hitting http://localhost:8888/start
in the browser, i am getting request.url is start only instead of full url. Hence path name is coming undefined.
Following is the console out put
Server has started11.
request url issss /start/
Request for undefined received
Thanks,
Shantanu
Upvotes: 0
Views: 682