nodeJS中通过URL发送的参数数量

时间:2016-05-05 06:46:13

标签: javascript node.js express

我需要查找网址中发送的参数数量。

如何确定nodeJS中通过URL发送的参数数量?

2 个答案:

答案 0 :(得分:3)

如果使用快递框架

req.params // can be used

See the documentation here

答案 1 :(得分:2)

使用req.query

如果您的网址与localhost:3000?param1=&param2=

相似
var params = req.query;
van length = Object.keys(params).length;

长度为2。