我试图弄清楚如何从节点请求中获取请求类型.我想根据类型执行不同的任务.
module.exports = function(req, resp, next){
if (req.type == 'GET'){
//Do something
}else{
// Do else something
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
app.use('/', (req, res, next) => {
let requestMethod = req.method;
console.log(requestMethod);
res.send('ok');
});Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5186 次 |
| 最近记录: |