I'm trying to do this:
var error = (reason) => {
console.log(reason);
};
//actually other promise
Promise.resolve()
.catch(error())
.then(render(req, res));
How can I pass the reason to the error function?
I'm trying to do this:
var error = (reason) => {
console.log(reason);
};
//actually other promise
Promise.resolve()
.catch(error())
.then(render(req, res));
How can I pass the reason to the error function?
You have to use catch(error) instead of catch(error()).
The catch method expects a Function as argument. To actually add the named function itself, just type error. If you type error(), the method will be executed first. As a result, it will log "undefined" and, as the function does not return anything, is evaluated to "undefined" as well. So what you essentially call is catch(undefined).
Use catch(error) instead of catch(error()) to provide the function defined in the var error