I am trying to parse some JSON data from randomuser.me api to do this, find some tutorials on the Internet, but something seems to have changed lately in Ionic 2 because none of them work.
Here is what I have:
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {Http} from '@angular/http';
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
items : any;
constructor(private navController: NavController, private http: Http) {
this.http.get("http://api.randomuser.me/?results=10").subscribe(data => {
console.log("Got data");
this.items=JSON.parse(data._body).results;
console.log(this.items);
});
}
itemClicked(event, item) {
console.log(item.title);
}
}
In the terminal, I see an error:
data._body - the "_body" property is private and is available only in the "Answer" class.
What can I do?
source
share