Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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中的http.get和查询字符串_Node.js_Express - Fatal编程技术网

node.js中的http.get和查询字符串

node.js中的http.get和查询字符串,node.js,express,Node.js,Express,在Node.js(使用Express.js)中,当我调用http.request时,如下所示: var options = { host: '127.0.0.1', port: 80, path: '/', query: {name: "John Doe", age: 50} // <---- problem here }; http.request(options, function(response) { ... }); var选项={ 主持人:“12

在Node.js(使用Express.js)中,当我调用
http.request
时,如下所示:

var options = {
    host: '127.0.0.1',
    port: 80,
    path: '/',
    query: {name: "John Doe", age: 50} // <---- problem here
};
http.request(options, function(response) { ... });
var选项={
主持人:“127.0.0.1”,
港口:80,
路径:“/”,

查询:{name:“John Doe”,年龄:50}/{string,number}。

您要查找的是查询字符串库

而且,您可能对这个HTTP客户机请求库感兴趣


谢谢!在紧要关头救了我的命。JSON.stringify呢?
var qs = require('querystring');
qs.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
// returns
'foo=bar&baz=qux&baz=quux&corge='