Express.js: how to make app.get('/[:userId]i'..) in req.param?

核能气质少年 提交于 2019-11-30 20:57:12
travis

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 ]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!