Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

488
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda