make request and response available in scope node js
I have this module.exports
module.exports = {
defaultStrings: function() {
return "Hello World" +
"Foo - Bar";
},
urlSlug: function(s) {
return s.toLowerCase().replace(/[^\w\s]+/g,'').replace(/\s+/g,'-');
}
};
I want to be able to use request or response inside function
defaultStrings how would I include that with a minimum change of the given
code?
defaultStrings: function(req, res, next) { // <--- This is not working
it says Cannot call method 'someGlobalFunction' of undefined
return "Hello World" +
"Foo - Bar" + req.someGlobalFunction();
},
No comments:
Post a Comment