How do you call a function from within another function in a module.exports declaration?
var bla = require('./bla.js');
console.log(bla.bar());
bla.js
module.exports = {
foo: function (req, res, next) {
return ('foo');
},
bar: function(req, res, next) {
this.foo();
}
}
I'm trying to access the function foo from within the function bar, and I'm getting:
TypeError: Object # has no method 'foo'
If I change this.foo() to just foo() I get:
ReferenceError: foo is not defined
v8.12.0and does no longer throw the error.barhas no return statement so runningconsole.log(bla.bar())simply returnsundefined