Why do both Promise’s then & catch callbacks get called?

The then callback gets called because the catch callback is before it, not after. The rejection has already been handled by catch. If you change the the order (i.e. (promise.then(...).catch(...))), the then callback won’t be executed.

MDN says that the .catch() method “returns a new promise resolving to the return value of the callback”. Your catch callback doesn’t return anything, so the promise is resolved with undefined value.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)