我正在尝试使用angular 4来调用虚拟web api,这是我的组件
export class AppComponent { title = 'app'; url = 'https://api.ipify.org/?format=json'; results: any; constructor(private http: Http) { this.getData().subscribe(data => { this.results = data.json(); }) } getData() { return this.http.get(this.url); } }
ERROR TypeError: Cannot read property 'ip' of undefined