Reputation: 147
const http = require('http');
const server = http.createServer((res, req) => {
res.write("Welcome to our home page");
res.end();
})
server.listen(5000);
I compiled the code using node filename.js
. However it is showing res.write()
is not a function. At times the error is not showing until I try to access the localhost
.
Upvotes: 0
Views: 84
Reputation: 22817
You flipped the parameters - req
(request) goes first:
const server = http.createServer((req, res) => {
res.write("Welcome to our home page");
res.end();
});
Upvotes: 5