GIPHY APIからいくつかのデータを取得するために、角度2を使用しています。GIPHY APIのオブジェクトは何も印刷しません。
export class ListaGifsComponent {
gifs : Object[] = [];
urlBase = "http://api.giphy.com/v1/gifs/search?q=";
termoPesquisado = "ryan+gosling";
key = "O8RhkTXfiSPmSCHosPAnhO70pdnHUiWn";
constructor(http: Http){
http
.get(this.urlBase + this.termoPesquisado +
"&api_key=" + this.key + "&limit=10")
.map(res => res.json())
.subscribe(gifs =>
this.gifs = gifs['data'],
erro => console.log(erro)
);
}
}
console.log(this.gifs)を書き込むと、何も記録されません。
しかし、私がconsole.log(gifs)をarrow関数の中から書くと、私は必要なオブジェクトを出力します。
私は何をしますか?
サービスがコンソールで呼び出された後でデータを確認できますか? 'console.log(this.gifs)'? – Niladri