Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!