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
  • 7,413
  • 13
  • 50
  • 94

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,755
  • 3
  • 36
  • 57