获取get的请求参数
get —— query
http://localhost:8080/?age=12
app.get('/', function (req, res) {
var params = req.query
res.send(params)
})
//{"age": "12"}
get —— params
http://localhost:8080/13
app.get('/:id', function (req, res) {
var params = req.params
res.send(params)
})
// {"id": "13"}
获取post的请求参数
app.post('/post', function (req, res) {
var params = req.body
console.log(params)
//{ params1: 'post_p1', params2: 'post_p2' }
})