title: Using exports in nodejs to return a value
body: <p>I've been doing some reading on modularizing my code and decided to export some functions to a separate file and include them in my main function once it's called.</p>
  
  <p>So I have two files, <code>index.js</code> and <code>weather.js</code>.</p>
  
  <p>In my <code>weather.js</code> file I have :</p>
  
  <p>"use strict";</p>
  
  <pre><code>exports.sometest = sometest;
  
  function sometest() {
      request('http://api.openweathermap.org/data/2.5/weather?&amp;appid=' + process.env.weather_api_key + '', (error, response, body) =&gt; {
        return body;
      });
  }
  </code></pre>
  
  <p>Then in my <code>index.js</code> file I include it <code>const testing = require("../../../lib/weather");</code>.</p>
  
  <p>So how can I user the data I return within the function I've created? And could someone explain to me how it works, I'm a little confused in terms of scoping and syntax etc</p>
  
  <p>Thank you.</p>