Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda