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

Popular posts from this blog

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

maven - jacoco coverage per test setup -