Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how-to-pass-data-between-middleware

exports.list_all_Demonstrator = function(req, res,next) {
//console.log(req.body)
Demonstrator.find({},  function(err, demo) {
    if (err){
        console.log(err);
    }
    else {
        res.locals.myvar = demo;    
    }
    next(); // <------------
});

};

exports.doSomeStuff = function(req,res,next) {
    var data;
    data = res.locals.myvar
    console.log("Dies ist 2te Funktion:", data);
    res.send(data);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
3+9 =