1

我想将poloniex api导入我的服务以使用 returnTicker() 函数,但每当我控制台记录接收到的数据时,它总是未定义

这是我的 Poloniex.ts 代码:

import {Injectable,Inject} from '@angular/core';
import {Observable} from 'rxjs/Obervable';
import 'rxjs/Rx';
import Poloniex from 'poloniex-api-node';

@Injectable()
export class PoloniexService{
  apiKey:string;
  secretKey:string;
  poloniex;
  constructor(){
    console.log('service is ready...');
    this.apiKey = 'api_key';
    this.secretKey = 'secret_key';

    this.poloniex = new Poloniex(this.apiKey, this.secretKey);
    //test returnTicker function
    this.poloniex.ticker((err, response) => {
      if (err) {
        // Log error message
        console.log("An error occurred: " + err.msg);

        // Disconnect
        return true;
      }

      // Log raw response
      console.log(response);
    });

  }

}
4

0 回答 0