title: Axios GET request returning empty object
body: <p>The 'getData' function in the 'dataService' class performs a GET request to the API and the console.log in the 'updateData' function does print the right information but an empty object is returned for 'http://localhost:xxxx/api/data'. I think it is due to a problem with asynchronous but I can't figure out how to fix it. Any ideas?</p>
  <p>dataService.ts:</p>
  <pre><code>import { Format } from '../types';
  
  import axios from 'axios';
  
  
  const token = process.env.TOKEN;
  
  const url = `https://www.something.com/somequery?someapikey=${token}`;
  
  const getData = async () =&gt; {
    try {
      const response = await axios.get&lt;Format&gt;(url);
      return response.data;
    } catch (error) {
      console.error(error);
    }
  };
  
  const updateData = async (): Promise&lt;Format | undefined&gt; =&gt; {
    const allData = await getData();
    console.log(allData, 'allData in backend');
    //edit allData to suitable format here
    return allData;
  };
  
  export default {
    updateData
  };
  </code></pre>
  <p>data.ts:</p>
  <pre><code>import express from 'express';
  import dataService from '../services/dataService';
  
  const router = express.Router();
  
  router.get('/', (_req, res) =&gt; {
    res.send(dataService.updateData());
  });
  
  export default router;
  </code></pre>
  <p>index.ts:</p>
  <pre><code>import express from 'express';
  const app = express();
  
  ...
  
  import dataRouter from './routes/data';
  
  ...
  
  app.use(express.json());
  
  ...
  
  app.use('/api/data', dataRouter);
  
  ...
  </code></pre>