I'm trying to consume json coming from a webapi. When debugging, the data is coming through correctly as per picture below:
Surprisingly when I try to loop through the objects in the report.subreport array, I get told it's undefined:
getReports() {
console.log('Get Reports');
this.staticEventsService.getReports().subscribe((rep) => {
this.reports = rep as Report[];
// eslint-disable-next-line no-debugger
debugger;
this.reports.forEach(r => {
r.subreport.forEach(s => { console.log('subreport = ' + s.categoryId);});});
console.log('show me the god damn reports = ' + this.reports);
});
I've declared these classes to deal with the incoming data:
export class Report {
month: number;
subreport: SubReport[];
};
export class SubReport {
categoryId: number;
occurrences: number;
}

