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();
},
In my app.js
I require the file in
strings = require('./lib/strings'),
And this is how it is being called inside app.js
app.get('/',
middleware.setSomeOperation,
routes.index(strings);