I am working with an object array that is being sent from an API. Right now, it is displaying the index position, but I actually want to display the object key and its corresponding value. I believe I may be mapping the object key incorrectly. Could anyone provide assistance with this issue?
getFav(): void {
this.Shared.getFav().subscribe(
data => {
this.fave = data.message;
Object.keys(this.fave).map((keyName) => {
return {id: keyName, product: this.fave[keyName]};
});
}
);
}
<div class="uk-width-small" uk-dropdown>
<div class="uk-dropdown-grid uk-child-width-1-1@m" uk-grid>
<div *ngFor="let fav of fave | keyvalue" >
<span>{{fav.value}}</span>
<span>{{fav.key}}</span>
<a href="{{fav.key}}"><li>Buy On amazon<br/>
</li></a>
</div>
</div>
</div>
https://i.sstatic.net/SDDOd.png
The current response from my API is showing the index positions. Do I need to make changes on the backend or can I adjust something on the frontend to only display the title key and its value? https://i.sstatic.net/wxDLD.png