calling exports.start in same js file node.js
Hi this is my method in a node js file:
exports.start = function() {
console.log(' in start of sender.js');
});
How can I call this method in the same js file? I tried calling start() and exports.start() but not successful.
Use this code:
var start = exports.start = function() {
console.log(' in start of sender.js');
});
or
function start() {
console.log(' in start of sender.js');
});
exports.start = start;
//you can call start();
exports.start = function(){
console.log('testing...')
}
You can call this method like this
exports.start();
You can call the exported function like this
module.exports.functionName(arguments);
Your named function:
var start = function() {
console.log(' in start of sender.js');
});
And later export object:
module.exports = {start : start}
So you can call start()
in the same js file