angular2 无法在 ng2-facebook-sdk 中使用 api 方法来获取用户数据

Cannot use api method in ng2-facebook-sdk for angular2 to fetch user data

有人用过ng2-facebook-sdk这个组件吗?如果是这样,有人知道我将如何使用 .api 方法从图 api 中获取用户数据。 这是 npm 包自述文件的 link guide.I 无法理解如何使用它 - https://www.npmjs.com/package/ng2-facebook-sdk。 我的问题是我已成功登录用户,但我无法编写 .api 函数,其中 returns 一个 Promise 对象

目前我的代码是这样的...

import { Component } from "@angular/core";
import {FacebookService, FacebookInitParams} from "ng2-facebook-sdk";
import { Http } from "@angular/http";
import * as http from "selenium-webdriver/http";

 @Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 styleUrls: ['./app.component.css']
 })
 export class AppComponent {

 name = "";
 isUser = false;
  no = false;

 constructor(private _facebookService: FacebookService,private http:Http) {
 let fbParams: FacebookInitParams = {
  appId: 'xxxxxxxxxxxxxxx',
  xfbml: true,
  version: 'v2.6'
};

  this._facebookService.init(fbParams);
}


login() {
  this._facebookService.login().then((response) => {
   this.getUserData();
   console.log(response);

 });
}

getUserData(){

  this._facebookService.api('/me', http,(res) {

  this.name = res.name;
   this.isUser = true;
  });

}
}

我自己想出来了。我没有正确处理 Promise 对象响应。 这应该是登录功能 ->

login() {
this._facebookService.login().then((response) => {
  var promise = this._facebookService.api('/me');
  promise.then((res)=> {
    this.id = res.id;
      this.name = res.name;
      this.isUser = true ;
      console.log(res);

    });
  console.log(response);

});

}