I have successfully implemented an API to retrieve data and display it on the page. It works perfectly for a json response containing more than one object, as it follows a "matches" hierarchy. However, I am facing an issue when trying to print out data for just one object.
The Json that is working and displaying properly is:
https://i.sstatic.net/M72Dw.png
Here is the code snippet that is working:
<ion-content>
<ion-list>
<ion-item *ngFor="let item of api" [navPush] = "detailsPage" detail-push>
<div class="thumb">
<img src="{{item.smallImageUrls}}">
</div>
<div class="text">
<div class="title">
<h1>{{item.recipeName}}</h1>
</div>
<div class="rating">
<rating [(ngModel)]="item.rating"></rating>
</div>
<div class="time">
<p>{{item.totalTimeInSeconds | HoursMinutesSeconds}} minutes</p>
</div>
<div class="ingredients">
<p>{{item.ingredients.length}} Ingredients</p>
</div>
<div class="course">
<p>{{item.attributes.course}} </p>
</div>
</div>
</ion-item>
</ion-list>
</ion-content>
Typescript code:
this.http.get('http://api.yummly.com/v1/api/recipes?_app_id=397aed16&_app_key=69e2565adcec7a6609b18bef31261e62')
.map(res => res.json())
.subscribe(data => {
console.log(data);
this.listing = data.matches;
resolve(this.listing);
});
I am currently stuck while working with the following Json:
https://i.sstatic.net/M72Dw.png
This is my request:
this.http.get('mylink.co.uk')
.map(res => res.json())
.subscribe(data => {
console.log(data);
this.details = data;
resolve(this.details);
});
And in Angular, I'm trying to display {{attribution}}
If anyone could provide some guidance on where I might be making a mistake, that would be highly appreciated.