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

337
Vistas
Uncaught TypeError: a is undefined

I have this:

let dateDataStartDate = moment().startOf('week')._d
let dateDataEndDate = moment().endOf('week')._d
if (datesData.start != undefined) {
  dateDataStartDate = datesData.start
  dateDataEndDate = datesData.end
}

axios.get('/api/classes/' + props.myVal, {
      params: {
          dateDataStartDate: dateDataStartDate,
          dateDataEndDate: dateDataEndDate,
          admin: true
      }
  })

when I run this code, I get this error:

Uncaught TypeError: a is undefined

and this error corresponds to this line from my console output:

let dateDataEndDate = moment().endOf('week')._d

Does anyone have any idea what the problem could be?

UPDATE

Problem was solved by fixing if (datesData.start != undefined) {

what was happening was that datesData is undefined, which means the object element .start doesn't exist. So it seems that I am trying to access a non-existent object element, and it was failing. So to fix it, I did:

if (datesData != undefined) {

weird, but it works

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can tell that the error is not within your code snippet

By the time the error occurs, in your 2nd line, there is no variable a.

let dateDataStartDate = moment().startOf('week')._d
let dateDataEndDate = moment().endOf('week')._d
if (datesData.start != undefined) {
  dateDataStartDate = datesData.start
  dateDataEndDate = datesData.end
}

axios.get('/api/classes/' + props.myVal, {
      params: {
          dateDataStartDate: dateDataStartDate,
          dateDataEndDate: dateDataEndDate,
          admin: true
      }
  })

If the error really is coming from that line, then it can't be from failure to define moment(), since it got past the first line.

Therefore there must be something wrong with the moment software, and probably in its endOf() module.

As @Mithiridi Prasanth says, do check that you are using an up to date version of NodeJs.

Debugging

Remove all the lines except the line causing the error

Are you still getting the error, and in the same line?

That line is not using any variables previously declared, and the later lines can't be the cause of the earlier error, if you are right about the site of the error.

Try a less deep access into moment()

let test1 = moment()
let test2 = moment().endOf
let test3 = moment().endOf('week')
let test4 = moment().endOf('week')._d

And console.log the results. That way you can see at what stage it is going wrong.

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