I've newly been trying out the Ionic framework. I'm currently trying to make a movie reviews app, using this movie reviews API.
I'm able to retrieve the JSON successfully, but not able to extract the data.
Controller code:
constructor(public navCtrl: NavController, public http: Http) {
this.http.get('https://api.nytimes.com/svc/movies/v2/reviews/all.json?api-key=a96736504fda41f58b3af1ec5876d3b9')
.map(res => res.json())
.subscribe(data => {
this.posts = data.results;
});
}
HTML code:
<ion-content>
<ion-list>
<ion-item ng-repeat = "post in posts">
{{post.display_title}}
</ion-item>
</ion-list>
</ion-content>
I get the error
Cannot read property 'display_title' of undefined.
But there is a field for display_title. Where am I going wrong?
this.posts = []in constructor, beforethis.http.getoperation