简体   繁体   中英

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?

api的响应可以是data.data,具体取决于您的后端

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM