javascript - Use named function to catch errors in promises? -
i'm trying this:
var error = (reason) => { console.log(reason); }; //actually other promise promise.resolve() .catch(error()) .then(render(req, res)); how can pass reason error function?
you have use catch(error) instead of catch(error()).
the catch method expects function argument. add named function itself, type error. if type error(), method executed first. result, log "undefined" and, function not return anything, evaluated "undefined" well. call catch(undefined).
Comments
Post a Comment