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

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -