I'm having trouble accessing the returned value of an imported module function in Node.
So, I have a simple function that returns a string. This is defined in a variable in my module code and exported:
var string = function() {
console.log('ran');
return 'string';
};
module.exports = string;
Then I require this in the usual way and assign to a variable. Finally, I console.log the variable, expecting 'ran' followed by 'string'.
var String = require('./string-module');
var stringInstance = new String();
console.log(stringInstance);
Instead, I get 'ran' (which I logged to check the function ran correctly / pathing was correct) followed by an empty object ({}) in my console.
I'm new to working with Node modules and I suspect I'm missing something regarding synchronous and asynchronous code.
Many thanks!