I have a weird error:
var http = require(\"http\");
var request = require(\"request\");
http.createServer(function(request, response) {
response.writeHead(2
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);