Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

489
Views
ERROR: 'Unhandled Promise rejection: TypeError: Cannot read properties of undefined

Getting this error when run ng test.

TypeError: Cannot read properties of undefined (reading 'id')

  this.slotSvc.getFiscalWeek(startDate, 1)
      .then(function (data) {
          const inductionYear = (data[0].id).split('-')[1];
          const shopId = slot.shop.id;
          const ohLines = [];
          this.slotSvc.getOlLinesForShop(shopId, inductionYear)
              .subscribe(function (d) {
                  _.each(d, function (dataOL) {
                      let slotLineType;
                      if (slot.linetype) {
                          slotLineType = slot.linetype;
                      } else {
                          slotLineType = slot.assignedAssetInfo.lineTypes[0];
                      }
                      if (dataOL.lineTypes[0] === slotLineType && dataOL.name.includes(slot.assetType)) {
                          const olJson = { 'id': dataOL.id, 'displayName': dataOL.displayName };
                          ohLines.push(olJson);
                      }
                  }.bind(this));
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Seems like you are accessing id props from data that does not exists. Try to monitor data params and log data if it contains id prop or not.

about 4 years ago · Juan Pablo Isaza Report

0

you can do like this const inductionYear = (data[0]?.id).split('-')[1];

after putting question mark it will not give any undefined error.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!