Executing functions in series
Posted
by
Latanmos
on Stack Overflow
See other posts from Stack Overflow
or by Latanmos
Published on 2011-01-01T20:43:57Z
Indexed on
2011/01/01
20:54 UTC
Read the original article
Hit count: 208
Hi,
First of all... Happy new year!
Could you please explain to me, how does this work? I browsed throught Connect's (https://github.com/senchalabs/connect) source code, but I don't get it.
I would like to write it by myself.
app.get(
'/',
function(req, res, next) {
// Set variable
req.var = 'Happy new year!';
// Go to next function
next();
},
function(req, res, next) {
// Returns 'Happy new year!'
console.log(req.var); // <- HOW IS THIS POSSIBLE?
// (...)
}
);
Thanks in advance!
© Stack Overflow or respective owner