This error occurs when - for example - you want to access properties inside of an array, but it turns out to be an object:

*ngFor="let item of results.rss.channel[0].item"

The error:

main.js:1 ERROR TypeError: Cannot read properties of undefined (reading 'channel')

Solution

The template searched for object keys inside 'results' in this case. But at the time, the results object was still empty, hence there was no values yet inside "channel". 

You have to make sure the object keys exist first:

<ion-list *ngIf="results.hasOwnProperty('rss')">
    <ion-item *ngFor="let item of results.rss.channel[0].item">

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!