2

How can I get GET parameters in an express route?

# requested path: /foo/1234?x=9
router.get('/foo/:id', function(req,res){
    console.info(req.params.id); // 1234 - my url segment
    ?????; // 9
});
boop
  • 6,834
  • 11
  • 47
  • 84

1 Answers1

1

You could get that by using req.query

http://expressjs.com/api.html#req

Just add this line

var x = req.query.x;
Tim
  • 3,585
  • 3
  • 34
  • 57