我正在使用 NODE.js 我正在使用“请求”模块:
有用:
var request = require('request');
request('http://www.site.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
});
当我尝试包含参数时,它会崩溃!
var request = require('request');
request('http://www.site.com/index.php?action=y9sadf98yh', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
});
Error: undefined is not a valid uri or options object.
at request (/node_modules/request/index.js:1217:41)
at Request._callback (nodeCloseSession/index.js:60:5)
at Request.self.callback (/node_modules/request/index.js:148:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/node_modules/request/index.js:876:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/node_modules/request/index.js:827:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:883:14
at process._tickCallback (node.js:415:13)
如何在 NODE.js 'request' 模块中使用参数?