Issue
Question – I am trying to filter the image property of this json response.
Some of the arrays dont contain images and therefore I want to filter them out.
New to angular and typescript.
this.music.searchArtists(this.searchQuery).subscribe(
data =>{
this.results = data.artists.items;
console.log(this.results);
}
)
2 contains images, 3 does not (therfore want to exclude it)
Solution
Try this.
this.results = data.artists.items.filter(item => item.images.length > 0);