There are two data types to get using promise if they are found:
card is not foundterminal is not found.a) If card is not found run:
response.status(293);
response.end();
a) If terminal is not found run:
response.status(292);
response.end();
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
});
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?