Google财务示例返回未定义且不适用

时间:2018-08-17 06:13:49

标签: node.js google-finance-api

我一直在看以下示例: https://github.com/pilwon/node-google-finance/blob/master/examples/callback/historical-multiple.js

但是我不断得到: 未定义,不适用

我想知道自己在做什么错,这是我正在使用的代码

var util = require('util');

//require('colors');

var googleFinance = require('google-finance');

var SYMBOL = 'NASDAQ:AAPL';
var FROM = '2014-01-01';
var TO = '2014-12-31';

googleFinance.historical({
  symbol: SYMBOL,
  from: FROM,
  to: TO
}, function (err, quotes) {
  if (err) { throw err; }
  console.log(util.format(
    '=== %s (%d) ===',
    SYMBOL,
    quotes.length
  ).cyan);
  if (quotes[0]) {
    console.log(
      '%s\n...\n%s',
      JSON.stringify(quotes[0], null, 2),
      JSON.stringify(quotes[quotes.length - 1], null, 2)
    );
  } else {
    console.log('N/A');
  }
});

0 个答案:

没有答案
相关问题