Basically it says that $request.post(…).then(…).catch is not a function. So, I want to know if .catch works or not in a serverless app or I need to do something else.
It is because according to $request, $db a successful response from the external server($request) and Db service respectively is still a success. Only if the services are down, the catch is reached. That’s the reason both response and error object are resolved
Adding on to @shravan.balasubraman, the confusion on the catch block might also arise due to the promise polyfills used in the APIs.
For example, if we observe the Request API behavior, (Server-Side) It would result in an error if an ES6 promise-styled catch block is used.
I realize that this might’ve resulted in a mismatch and have noted it as a feedback ! A good thing is that there is a common pattern that works across all regardless of the polyfills. This is what @samuelpares has recommended in his solution too.
ES6 Promise behavior (without an explicit catch block. error handled in the second fn. arg)
Although this is a nuance in the way promises operate in the context of the developer platform, it could definitely remove a lot of confusion down the lane.