check if there is a next() function express check if there is a next() function express express express

check if there is a next() function express


thanks to paul i was able to work around the next issue kind of.currently this working

function findAll(callback){    return function send(req, res){        db.findAll(function(err, docs){            if(callback){                req.docs = docs                return callback(req, res, next());            }            res.render('table', {docs:docs});        });    }}function handleData(req, res, next){    res.send(req.docs);}

will work with

router.get('/', findAll());

or

router.get('/', findAll(handleData));


SnymaxYou can check in the function if next is defined or not.If defined you can call next andif not do what you want.

WORKED FOR ME.

    function findAll(req, res, next){      db.findAll(function(err, docs){        if(typeof next != "undefined"){            req.list = docs            return next();        }else{            res.render('table', {list:docs};        }      });    }

I hope it helps.

Thank You