我在使用request module执行非常基本的GET请求时遇到错误。
这是我的代码:
var request = require('request');
var url = 'http://www.bigassfans.com/case-studies/delphine-restaurant/';
request({
url : url,
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36'
}
}, function(error, response, html){
console.log(response.statusCode);
console.log(response.headers);
});
这是我的错误消息:
(node:75952)警告:检测到可能的EventEmitter内存泄漏。增加了11名管道听众。使用emitter.setMaxListeners()来增加限制
(node:75952)警告:检测到可能的EventEmitter内存泄漏。增加了11名管道听众。使用emitter.setMaxListeners()来增加限制
TypeError:无法读取属性' statusCode'未定义的
at Request._callback (/foo/foo.js:10:29) at self.callback (/foo/node_modules/request/request.js:200:22) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Redirect.onResponse (/foo/node_modules/request/lib/redirect.js:94:13) at Request.onRequestResponse (/foo/node_modules/request/request.js:908:22) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:469:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
发生了什么?这是请求模块中的错误还是我的代码有问题?