Uncaught (in promise): TypeError: Cannot read property 'length' of undefined


#1

This is my typescript code

export class FailedPage {

  failedjobs: Array<any> = [];

  constructor(public navCtrl: NavController, 
              public navParams: NavParams, public jobfailList: JobActionsProvider) {
  }

  ionViewDidLoad() {
    console.log('FailedPage');
    // getting jobs from job-actions file and displaying
    this.jobfailList.getfailedjobList().then((data) => {
      console.log('displaying failed job list');
      for (let values of data) {
        this.failedjobs.push(values);
      }
    });
  }

}

I’m facing error as

Uncaught (in promise): TypeError: Cannot read property ‘length’ of undefined
TypeError: Cannot read property ‘length’ of undefined
at failed.ts:24

How can I fix this?


#2

Hello,

whatever from whatever.lenght does not exist at the time you call it. I guess it is data. Check it.

Best regrads, anna-liebt