Express Router: How do I get parameters? (not URL segments)

877 views Asked by At

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
});
1

There are 1 answers

0
Tim On BEST ANSWER

You could get that by using req.query

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

Just add this line

var x = req.query.x;