title: How to wait for all .then are finished before returning value
body: <p>I have the following function</p>
  <pre><code>const getQuotes = symbol =&gt; {
    let quotes = {};
    new DeltaRestClient(api_key, api_secret).then(client =&gt; {
      const linkOptions = createIdentifiers(symbol, false);
      Object.entries(linkOptions).forEach(entry =&gt; {
        client.apis.Products.getTicker({ symbol: entry[1] }).then(response =&gt; {
          const ticker = JSON.parse(response.data.toString());
          quotes[entry[0]] = parseFloat(ticker.result.close);
        });
      });
    });
    return quotes;
  };
  </code></pre>
  <p>which I call in</p>
  <pre><code>const start = async () =&gt; {
    const quotes = await getQuotes(&quot;ABCD&quot;);
    console.log(quotes);
  };
  </code></pre>
  <p>But because of the asynchronicity, getQuotes returns before all the .then are resolved and an empty object is returned.</p>
  <p>How can I change this such that the value is only returned if all .then are resolved?</p>