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

102
Vistas
catch inside the resolved promise doesn't change response.status()

There are two data types to get using promise if they are found:

  • The parent promise is rejected if the card is not found
  • The second/child promise is expected to reject if the terminal is not found.

Expected behavior:

a) If card is not found run:

response.status(293);
response.end();

a) If terminal is not found run:

response.status(292);
response.end();

Code example

getCard(cardID)
  .then((card: Card) => {
    getTerminal(terminalID)
      .then((terminal: Terminal) => {
        // do smth
      })
      .catch((e) => {
        console.log(e); // log works fine
        response.status(292);
        // terminal does not exist
      });
    })
  .catch((e) => {
    console.log(e);
    response.status(293);
    // card doesn't exist
  })
  .finally(() => {
    response.end();
    // close connection
  });

Problem:

The server returns 200 status in all cases other than 293, the first catch(), which is the only one that is executed as expected. I have a guess that it should be sequential promises, not child-parent based. How do we achieve that?

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