Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting ReferenceError: Response is not defined? [closed]

I am using node.js with express. I am trying to set up a basic server, but have no idea why I am getting a response error.

var http = require('http');

var myServer = http.createServer(function(req,res){
    response.writeHead(200, {"Content-Type" : "text/plain"});
    response.write('Hello World');
    response.end();
});

myServer.listen(3000);
like image 215
Edward K. Avatar asked Apr 28 '17 00:04

Edward K.


1 Answers

function(req,res)

is supposed to be

function(req, response) {

You don't have a variable named response in the scope of the callback. That is the reason for the reference error

like image 90
Sushanth -- Avatar answered Sep 22 '22 02:09

Sushanth --