I am currently facing an issue while trying to retrieve data from an array. Below is an example of the image array that I am working with. I am specifically looking to get the weather icon data, but unfortunately I encountered this error message:
core.js:15724 ERROR TypeError: Cannot read property '0' of undefined
https://i.sstatic.net/i4dNK.png
Here is the code snippet:
weatherDaily(){
this.commonService.getWeatherInfoDaily()
.subscribe(
(res) => {
this.daily = res['list'];
this.icon = res['list']['weather'][0]['icon'];
console.log(this.icon);
}
)
}