NodeJS对象#没有方法'得到'

时间:2016-01-12 19:49:56

标签: javascript node.js

我试图向端点发出请求,该端点应该向我返回一些用户凭据,但是我收到了以下错误:

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');

0 个答案:

没有答案