I have a module.exports with multiple functions inside. What I have understod, it is possible to share a variable to another file. But I cannot seem to get it work.
translator.js
module.exports = {
  translatorfunc: function (message, queryInput, callback) {
    var parameters = {
      text: queryInput
    };
    var parameters = {
      text: queryInput,
      model_id: 'es-en'
    };
    languageTranslator.translate(
      parameters,
      function (error, response) {
        if (error)
          bot.reply(message, 'Cannot find language that should understand this.')//console.log(error)
        else
          var TranslatedOutput = response.translations[0].translation;
        assistant.message({
          input: { 'text': TranslatedOutput }
        }, function (err, response) {
          if (err)
            console.log('error:', err);
          else
            queryOutput = response.output.text[0];
          var parameters = {
            text: queryOutput,
            model_id: 'en-es'
          };
          languageTranslator.translate(
            parameters,
            function (error, response) {
              if (error)
                bot.reply(message, 'Cannot find language that should understand this.')//console.log(error)
              else
                TranslatedOutput = response.translations[0].translation;
            }
          )
        });
      }
    )
  }
}
The variable I'm trying to send to a different file is TranslatedOutput
I also tried to wrap the function languageTranslator.translate as a function, but when I'm calling the variable, it says undefined.
And to get the variable
var translator = require('./tools/translator')
console.log(translator.translatorfunc.TranslatedOutput);
 
     
    