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

178
Vistas
Cannot read properties of undefined (reading '0') - ( empty error JSON response with postman)

so i'm working with Joi for validation, and i've encountered this error when trying to post with postman.

i'm follwing a tutorial, i tried to write it differently, but still have the same issue.

i'm trying to access the error message. ( first selecting the error, then the details, then the message )

in the tutorial, it looks like this

res.send(error.details[0].message)

i can see the error, but once i select details, the response is empty.

let me know if you need anything else.

Thank you in advance.

The Lord be with you and save you all, your families and friends :)

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

0

It seems like error does not have a property called details. That's why error.details is undefined. Thus, when trying to access the element of the first index of the value undefined you'll get an error.

To fix:

  • Make sure the error object contains a property details of type Array
  • If error.details will depend on other code blocks (sometimes it is defined, sometimes it isn't), you can add a ternary expression to tell your code what to in case error.details is indeed undefined. Example:
err.details ? res.send(error.details[0].message) : res.send("error") 

Which translates to

if (err.details) { // if defined
 res.send(error.details[0].message) // Send the message from the error
} else {
 res.send("error") // Send a general message
} 
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