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

158
Vistas
How to return an Object Value if you have a specific key in your Object?

// If successfully created let sampleObject = { response: 'Generated ID from the application' }

// If error let sampleObject = { errorLog: 'Generated error message from the application' }

I have an object that returns different keys depending if it is successful or an error (see above sample code). If it is successful, it has a key of 'response' and has a value of ID generated, otherwise it has a key of 'errorLog' and has a value of the error message. Now I want to run an if statement with those keys. For example, if the key 'response' is present, I want to alert the user for the generated ID for successfully creating the data. But if the key 'errorLog' is present, I want to alert the user for the error message.

Can someone help me?

about 4 years ago · Juan Pablo Isaza
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