title: How to await on async function and collect the response
body: <p>Until now, I thought <code>await</code> makes my program synchronous. However, I see that <code>await</code> only waits for <code>async</code> function to be resolved with a promise then the whole programs continues to run. So, what is the right way to wait &amp; collect the response from async function?</p>
  
  <p>Original code:</p>
  
  <pre class="lang-js prettyprint-override"><code>let result={
    name:'',
    country:''
  };
  const data = await query.getCachedData(did); 
  result.name = data.name; // undefined
  result.country = data.country;//undefined
  console.log(result);
  </code></pre>
  
  <p>I don't know why but awaiting on the async function result works:</p>
  
  <pre class="lang-js prettyprint-override"><code>let result={
    name:'',
    country:''
  };
  const data = await query.getCachedData(did); 
  result.name = await data.name; //'Jon'
  result.country = await data.country;// 'US'
  console.log(result);
  </code></pre>
  
  <p>But I am not sure if this is the solution.</p>
  
  <p>Since <code>getCachedData</code> returns the promise, I thought this may be the right way but the <code>then()</code>/<code>catch()</code> didn't execute.</p>
  
  <pre class="lang-js prettyprint-override"><code>query.getCachedData(did).then((tfnData) =&gt; {
    result.name = data.name; 
    result.country = data.country;
    console.log(result);
  }).catch((dbError) =&gt; {
    console.log(dbError);
  });
  </code></pre>
  
  <p>Can anyone correct me to get the <code>result</code> the right way?</p>