title: What is the correct way to export an Async function module?
body: <p>I have a file <code>asyncAwait.js</code> that has a simple function:</p>
  
  <pre><code>async function doStuff() {
      return(`Function returned string.`);
  }
  
  module.exports.doStuff = doStuff;
  </code></pre>
  
  <p>In another module, <code>testing.js</code>, I invoke and all works as expected:</p>
  
  <pre><code>var functions = require(`./functions`);
  
  (async () =&gt; {
  
      const test = await functions.asyncAwait.doStuff();
  
      console.log(test);
  
  })();
  </code></pre>
  
  <p>This logs "Function returned string." to the console. </p>
  
  <p>All good.</p>
  
  <p>However, if I use axios in <code>asyncAwait.js</code>:</p>
  
  <pre><code>const axios = require(`axios`);
  
  async function doStuff(parameter) {
  
      const url = `https://jsonplaceholder.typicode.com/posts/1`;
  
      const getData = async url =&gt; {
          try {
              const response = await axios.get(url);
              const data = response.data;
              console.log(data);
          } catch (error) {
              console.log(error);
          }
      };
  
      return(getData(url));
  }
  
  module.exports.doStuff = doStuff;
  </code></pre>
  
  <p>Then in <code>testing.js</code>:</p>
  
  <pre><code>var functions = require(`./functions`);
  
  (async () =&gt; {
  
      const test = await functions.asyncAwait.doStuff();
  
      console.log(test);
  
  })();
  </code></pre>
  
  <p>This logs <code>undefined</code>.</p>
  
  <p>Why does the function call return undefined in the second example? </p>