English 中文(简体)
http.get and query string in node. j)
原标题:http.get and query string in node.js

在Node.js(使用快递)中,我打电话http://quest/code>。 类似:

var options = {
    host:  127.0.0.1 ,
    port: 80,
    path:  / ,
    query: {name: "John Doe", age: 50} // <---- problem here
};
http.request(options, function(response) { ... });

除<代码>query部分备选办法被忽略外,所有选择都是好的。 文件指出,必须用人工方式构造查询,并在<条码>/代码>内通过: 比如path: /?name=John%20Doe&age=50/code>。

实现这一目标的最佳途径是什么? <代码>query是一种简单的体质->{string, number}。

最佳回答

http://nodejs.org/api/querystring.html

并且,你可能有兴趣了解吉大港定居地特许经营方案的客户要求图书馆

var qs = require( querystring );
qs.stringify({ foo:  bar , baz: [ qux ,  quux ], corge:    })
// returns
 foo=bar&baz=qux&baz=quux&corge= 
问题回答

暂无回答




相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签