简体   繁体   中英

Object properties are undefined

I get some data from my backend, and I want to make use of that data.

For some reason the properties are undefined when I try to access them, even though the data has come to the front-end.

This is what I get when I try to print them


在此处输入图片说明


I've looked at similar questions, but none of the ones I saw had any answers that were a solution for me.

What causes this? I use a promise to get the data(in case that has something to do with it).


this.driverService.getDrivers()
  .then((data: any) => {
    console.log(data); // prints the data like it should
    console.log(data['driverDataForDriverList']); // prints undefined
    console.log(data.driverDataForDriverList); // prints undefined
    this.driversData = data['driverDataForDriverList']; // assigns undefined...
  });

Please help, I'm a noob. Thanks.

尝试console.log(data.data['driverDataForDriverList'])

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