【发布时间】:2014-10-10 12:08:08
【问题描述】:
我猜这是一个简单的:
我想在Node.js 服务器上发出请求,因为我目前正在使用 cURL。无论我尝试什么,我都会从服务器收到错误 404。
这是我的有效 cURL 命令,它返回一个 JavaScript 对象:
curl --data "ajax=1&example=test" http://some-site-example.com
阅读cURL手册和请求手册后,这是我在Node.js中尝试的:
request.post({'content-type':'application/x-www-form-urlencoded',ajax:'1',example:'test',url:'http://some-site-example.com'}, function(err, result, body) {
if (err) console.log(err);
else console.log(body);
});
【问题讨论】:
-
是request模块吗??