node.js - What is alternative of php's $_SERVER in nodejs
one text
Solution:
Your node.js code has a syntax error, but you are checking correctly the method. You just have to end the request when you're done via res.end
so that the browser knows it got the full response.
var http = require('http');
http.createServer(function (req, res) {
console.log('Received "' + req.method + '" request!');
if (req.method === 'POST') {
res.end('This was a POST request');
return;
}
res.end('This was a GET request');
}).listen(8080);
Source