node.js - expressjs ignore next functions till reach spezified function -


i have queue of functions called through next. in normal case ok, have spezial scenario, want call same url not want step trough function. functions in middle of queue should not call.

i hope understandable mean.

so want tell next function ignore next function till reach function x. thing found next('route') jump last function in queue.

attach flag variable in request object

function first(req,res,next){ if(your scenario)  req.flag = true; } 

check variable inside other middlewares(functions)

function second(req,res,next){  if(req.flag) return next(); } 

passing data inside next wont work because next takes error parameter , reach error handling middleware


Comments