Ejemplo 1: expressjs req.body.parameters
app.get('/user/:id', (req, res) => {
console.log(req.params.id) // "1234562134654"
})
or
app.get('/user/:user_id', (req, res) => {
console.log(req.params.user_id) // "1234562134654"
})
Ejemplo 2: req.params vs req.body
//this is just for me lol
* req.user: object make by passport.js added to req that include a username and user id
* req.params: from path segments of URL that match a route definition parameter
* /song/:id
* req.body: hold parameters sent by post request (like form data)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)