2017-10-09 89 views
-1
getPrefectures() { 
    return this.http.get(this.PREFECTURE_API); 
} 

this.addressService.getPrefectures().subscribe((response) => { 
    this.prefectureData = response.json(); 
    this.updatePrefecture(); 
}); 

updatePrefecture() { 
    for (let d of this.prefectureData) { 
     console.log(d) 
    } 
} 

我以一般的方式從Angular API獲取JSON,但結果如下。爲什麼我無法在Angular4上正確解析JSON?

enter image description here

接下來是JSON原始數據。

enter image description here

我們如何正確地獲得數據?

謝謝。

+1

請勿使用圖片提供的代碼或其他文字材料。但是,你沒有通過迴應的身體,是嗎? – pzaenger

+0

對不起,下次我會小心點的。 –

回答

0

已解決。

this.prefectureData = JSON.parse(response.json()); 
相關問題