我试图向端点发出请求,该端点应该向我返回一些用户凭据,但是我收到了以下错误:
TypeError: Object # has no method 'get'\n at main:52:14\n at main:59:24
at new SandBox (/home/server/node-host/sandbox/index.js:66:9)
at builder.back (/home/server/node-host/test.js:48:17)
at builder.count (/home/server/node-host/sandbox/build.js:139:7)
at done (/home/server/node-host/sandbox/build.js:24:7)
at builder.compiler (/home/server/node-host/sandbox/build.js:62:2)
at new builder (/home/server/node-host/sandbox/build.js:13:10)
at Object. (/home/server/node-host/sandbox/build.js:143:13)
at Object.build (/home/server/node-host/sandbox/index.js:111:37)
这是我试图运行的代码(将敏感部分取出并替换为变量):
var http = require('http');
var options = {
hostname: 'HOST',
path: 'PATH',
protocol: 'https'
};
var req = http.get(options, function(response) {
response.on('data', function(chunk) {
console.log('BODY: ${chunk}');
});
});
req.write()
req.end()
console.log('ended');