156
rated 0 times
[
157]
[
1]
/ answers: 1 / hits: 26932
/ 9 Years ago, mon, october 12, 2015, 12:00:00
How do you call a function from within another function in a module.exports declaration?
I have MVC structure node js project and a controller called TestController.js. I want to access method within controller, but using this
keyword gives below error:
cannot call method getName of undefined
use strict
module.exports = {
myName : function(req, res, next) {
// accessing method within controller
this.getName(data);
},
getName : function(data) {
// code
}
}
How do I access methods within controller?
More From » node.js