0

I want to use GET, to get the value of a variable, inside a node.js page I made, as I would normally do (with $_GET) using PHP.

Here is how it looks:

http://mygreatpage.herokuapp.com/myThing?X=57

The question is:

How do I get the value of X (57 in the example above) inside my index.js file?

Michel
  • 10,303
  • 17
  • 82
  • 179

1 Answers1

0
var app = require('express')();
var http = require('http').Server(app);
app.get('/myThing',function(req,res)
console.log(req.query.X);
    res.send(req.query.X);
}
      );
app.listen(3000);
console.log("server start");

enter image description here

check this for more detail

check this for multiple param

Community
  • 1
  • 1
Adiii
  • 54,482
  • 7
  • 145
  • 148