params.id examples in express
Example 1: express route parameters
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
Example 2: express route parameters
Route path: /users/:userId/books/:bookId
Request URL: http://localhost:3000/users/34/books/8989
req.params: { "userId": "34", "bookId": "8989" }
Example 3: widlicard in express router
app.get('/ab?cd', function (req, res) {
res.send('ab?cd')
})
app.get('/ab+cd', function (req, res) {
res.send('ab+cd')
})
app.get('/ab*cd', function (req, res) {
res.send('ab*cd')
})
app.get('/ab(cd)?e', function (req, res) {
res.send('ab(cd)?e')
})
app.get(/a/, function (req, res) {
res.send('/a/')
})
app.get(/.*fly$/, function (req, res) {
res.send('/.*fly$/')
})