Hi,
I'm a Node.js newbie and have a middleware related question. Here is the
code:
// router starts controller()
...
exports.controller = function controller(req, res, next) {
model.getFileData("/tmp/foo.txt", function foo(err, data) {
if(err) {
console.log("error while reading file");
return(next(new Error()); *// exits foo() and NOT controller()*
}
console.log("success");
// do something with data
});
return(next());
}
If the model returns an error, I want to call controllers next() to jump to
the next middleware function.
I'm not sure how to organize the code, could you give me some examples?
Thank you
Aga
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en