title: Node.js export variable
body: <p>I am writing a Node.js module and I need to pass variable data from the main file to the functions. I am doing this:</p>
  <pre><code>var region;
  var api_key;
  
  exports.region = region;
  exports.api_key = api_key;
  
  
  module.exports = {
  
    getSummonerId: function(sum, callback) {
  
      var summoners = {};
      var summoner = sum.replace(/\s+/g, '');
  
      request(&quot;https://na.api.pvp.net/api/lol/&quot; + region + &quot;/v1.4/summoner/by-name/&quot; + summoner + &quot;?api_key=&quot; + api_key, function(error, response, body) {
        summoners[summoner] = JSON.parse(body);
        callback(summoners[summoner][summoner].id);
      });
    }
  }
  </code></pre>
  <p>And in the <b>main file</b>:</p>
  <pre><code>var lol = require('./apiwrapper.js');
  
  lol.api_key = &quot;example&quot;;
  lol.region  = &quot;las&quot;;
  
  
  lol.getChampions(function(data) {
    console.log(data);
  })
  </code></pre>
  <p>But from <b>apiwrapper.js</b> file, those two variables' value are always &quot;<b>undefined</b>&quot;.</p>
  <p>How can I fix this?</p>