Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js express req.headers,如何获取方法(get或post)_Node.js_Express - Fatal编程技术网

Node.js express req.headers,如何获取方法(get或post)

Node.js express req.headers,如何获取方法(get或post),node.js,express,Node.js,Express,我正在使用node和express,并正在为app.use()编写一个函数。它需要知道请求是GET还是POST 查看req.headers,似乎没有方法的属性 我是如何得到的,无论是一个得到还是一个帖子 req.method 方法包含一个与请求的HTTP方法相对应的字符串:GET、POST、PUT等等 我认为它在req.method下我认为你应该使用app.get(“*”。。。。。。

我正在使用node和express,并正在为app.use()编写一个函数。它需要知道请求是GET还是POST

查看req.headers,似乎没有方法的属性

我是如何得到的,无论是一个得到还是一个帖子

req.method
方法包含一个与请求的HTTP方法相对应的字符串:GET、POST、PUT等等


我认为它在
req.method下
我认为你应该使用app.get(“*”。。。。。。