I have a php script where I am using $_SERVER["REQUEST_METHOD"];
right at start of script. I then need to check what is request being sent like 'GET', 'POST' etc. Sharing some of the php script as below.
<?php
try {
$method_name = $_SERVER["REQUEST_METHOD"];
if ($_SERVER["REQUEST_METHOD"]) {
// more code
}
}
?>
What I trying currently is creating a new server with node as follow.
var http = require('http');
http.createServer(function (req, res) {
console.log(req.method).
if(req.method === 'POST') {
// more code
}
}).listen(8080);
Currently it is not working as my php script, any idea?