Tuesday 23 May 2017

How to route dynamic URL in Express

Say I have the following URL:

/page?name=myname&age=25

Where name and age have dynamic values.

How do I construct a router get function for this page?

Option 1:

router.route("/page").get(function(req, res) {
    console.log("got page");
}

Option 2:

router.route("/page?name&age").get(function(req, res) {
    console.log("got page");
}



via b11

No comments:

Post a Comment