javascript - 如何获取 express.js 中的所有参数(post/get/etc.)

标签 javascript node.js parameters express

有没有办法在使用 express.js 发送所有参数后进入?我知道如何分别知道 GET/POST,但是有没有办法同时获取所有内容?

到目前为止我还没有发现任何关于它的信息,它对调试特别有用。

当然 req.param(key) 可以工作,但我想要一个所有参数的列表,不必检索它们,只需查看它们即可。

编辑:添加路线信息:

consoleDev('Url: ' + req.method + ' ' + req.baseUrl + req._parsedUrl.href, 'debug');
consoleDev('Options: ' + JSON.stringify(options), 'debug');
consoleDev('Params: ' + Object.keys(req.params), 'debug');
consoleDev('Params: ' + (req.param('test')), 'debug');

控制台:

debug: Url: GET http://localhost:5000/?test=5000
debug: Options: {"controllerName":"home","methodName":"index"}
debug: Params: 
debug: Params: 5000

最佳答案

我忘了几个月前我创建了这个主题并创建了另一个我得到问题答案的主题:

You're looking for req.body, which contains the parsed POST body. (assuming you have middleware that parses it)

See express.bodyParser()

How log express.js POST parameters

关于javascript - 如何获取 express.js 中的所有参数(post/get/etc.),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21863415/

相关文章:

javascript - redux saga 和 history.push

javascript - 限制 google 位置条目到 AngularJS 中的建议列表

node.js - require() 左侧使用的变量名称是否存在标准?

将 void* 转换为 C 中的可变数据类型

c - 如何在 C 中打印函数参数?

javascript - jQuery 1.3.2 是否有可用的 md5 插件或等效的加密插件?

javascript - 多行 Google 折线图的工具提示

node.js - 从phonegap中的ajax调用调用node.js文件?

javascript - 使用 should.js 的单元测试 Number 失败

c - pthread_create 中使用的参数错误