I can't seem to figure this one out. I have a POST route that is creating a transaction through Stripe using Stripe's Node package.
It works fine until there is an error, say for an example a card with insufficient funds. When the error occurs it calls the catch()
block as it should. In the catch block I have return next(err)
. I am sure to use return
because there is other code after the promise that should only run upon success of stripe.charges.create
.
However, even with return next(err)
, it seems as if it continues to run, as illustrated by the console.log
I have in place. Additionally, the route returns a 200 status with the "Executed route" text.I also have a global error catcher right after this route. Please feel free to view the images attached below for more detail.
Anyone have any ideas as to why this may be occurring? I've done this structure plenty of times before with no issues; not quite sure what is going on.
Thanks for any input!