I have three middleware callbacks in a route. I want to bypass middleware callbacks and pass control to last callback.
A example code
var middleware = [loadData, loadForum, loadThread]; app.get('/forum/:fid/thread/:tid', middleware, finalMethod);
Use case: If first callback
loadData enters into strange case like failing to load data. I would like by pass
loadThread middleware callbacks and pass control to last route callback
next() is called in middleware callback, it will go to next callback.
If I understand correctly,
next('route') will go to other route given in argument of
next method, not to last route callback.
How to bypass middleware callbacks and pass control to last callback?
I am trying to avoid deep nested functions in methods. So I think to set middleware in routes, each nesting functions can be splitted into each method and setting it’s result in
request object. So that next middleware method can be access its result through
Is this good way to handle deep nested functions or any other good way to do this?