user9705886
user9705886

Reputation:

Ionic: Uncaught (in promise): TypeError: Cannot read property ‘length’ of undefined

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

Here 24 line is for (let values of data) How can I fix this?

Upvotes: 0

Views: 964

Answers (1)

Franco Coronel
Franco Coronel

Reputation: 730

The response from the api can be data.data it depends of your backend

Upvotes: 0

Related Questions