app.use("/getStudent", (req, res) => {
console.log(req.method)
})
app.use("/getStudent", (req, res) => {
console.log(req.headers)
})
-
req.query:
返回的是get请求的请求参数部分
app.use("/getStudent", (req, res) => {
console.log(req.query)
})
-
req.on():
默认的请求对象上是没有body属性的,只有通过post请求的中间件,才会在处理数据是将数据添加到req.body属性上去。
req.on('data', chunk => data += chunk);
req.on('end', () => console.log(data))
app.get('/qryStudent/:uid/:usex', (req, res, next) => {
let { uid, usex} = req.params;
console.log(uid, usex);
res.send({
"stuNo": uid,
"stuSex": usex
})
})

image1.png
网友评论