I have a weird error:
var http = require(\"http\");
var request = require(\"request\");
http.createServer(function(request, response) {
response.writeHead(2
You are no longer able to access the global variable 'request'. You need to rename your local variable 'request' with some other name and the problem will be resolved.
Access to the request
global variable is lost as you have a local variable with the same name. Renaming either one of the variables will solve this issue:
var http = require("http"); var request = require("request");
http.createServer(function(req, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print the google web page.
}
})
response.end();
}).listen(8888);