title: Need results of asynchronous functions in javascript code
body: <p>My background is mostly python so I'm struggling with this async-await paradigm right now. I understand the flow for simple things, but when it's complicated due to nestedness and chaining multiple sync/async pieces I'm not getting the results I was hoping for. Below is the stub that should sum up where I got stuck</p>
  <pre class="lang-js prettyprint-override"><code>const _ = require('underscore');
  const axios = require('axios').default;
  
  const func1 = async () =&gt; {
      let myObj = {1: [1, 2, 3], 2: [1, 2, 3], 3: [1, 2, 3]};
      let bigLst = [];
      _.each(Object.entries(myObj), async ([k, lst]) =&gt; {
          let rslt = await Promise.all(lst.map(func2));
          bigLst.push(rslt);
      });
      return bigLst; // but bigLst is empty :'(
  };
  
  const func2 = async (id) =&gt; {
      const rslt = await axios.get(f`https://some-url-${id}.com`);
      return rslt;
  };
  
  let final_rslt = func1(); // so is final_rslt
  </code></pre>
  <p><code>func1</code> doesn't have to return the final result, I can save it in a db or something like that, but the problem is it's still empty inside of the <code>func1</code> body after the <code>_.each</code> piece. So my question is - how do I collect results of multiple async calls into a one big object to either return or work with within the function.</p>
  <p>Thanks.</p>