I m using nodejs 0.8.21 and express 3.1.0
I need to read userId
from url like http://mysite.com/39i
. It means userId=39
.
How to do? Thank you.
Sample:
app.get('/:userId_i', function(req, res) { });
app.param('userId', function(req, res, next, id){ });
Assuming you have a numerical id followed by an i
and you want the id coming back as just the numerical.
app.get("/:id([0-9]+)i", function (req, res) {...});
This will match a numeric followed by an i
and will give you just the numeric in req.params.id
.
Example:
curl -XGET localhost:8080/124i
Gives me the following in req.params
[ 'id': 124 ]