I'm getting an error in the function call below saying that this.albumDetails is undefined for a specific line even though all other this calls are working fine.
the error is: TypeError: _this.albumDetails is undefined
The error probably occurs at this.albumDetails.concat(items) where items is an array of json objects
Any assistance is appreciated thanks.
export class AppComponent {
albums: any[];
albumDetails: any[];
searchAlbum(input: any){
this.show = true;
this.searchService.getAlbum(input).subscribe(data => {
this.albums = data;
for(var i = 0; i < 50; i++){
this.searchService.getDetails(this.albums[i].artist, this.albums[i].name, this.albums[i].mbid).subscribe(items => {
this.albumDetails = this.albumDetails.concat(items); //Error occuring here at this.albumDetails.concat(items)
console.log(this.albumDetails);
});
}
});
}
}