1var bodyParser = require('body-parser')
2var app = express()
3
4// parse application/x-www-form-urlencoded
5app.use(bodyParser.urlencoded({ extended: false }))
6
7// parse application/json
8app.use(bodyParser.json())
9
1app.post('/login', (req, res) => {
2 console.log(req.body.email) // "user@example.com"
3 console.log(req.body.password) // "helloworld"
4})
1app.get('/user/:id', (req, res) => {
2 console.log(req.params.id) // "1234562134654"
3})
4or
5app.get('/user/:user_id', (req, res) => {
6 console.log(req.params.user_id) // "1234562134654"
7})