title: Javascript - async await not wait until function is done?
body: <p>I was learning javascript with async and await and tried some example on my own, but it seems when calling the async function (func1) from another function (func2), func2 does not wait for func1 to complete its process and it jumps over and continue executing...is there something wrong with my code or should I also turn func2 into async and call func1 with await? If so, does that mean all functions that will involve an async-await method will need to become async as well?
  here is my original code</p>
  <pre><code>// func1
  const func1 = async() =&gt; {
     try {
       await putCallToServer(...);
       return 1;     // it returns as a promise
     } catch(ex) {
       return 2;
     }
  }
  
  // func2
  const func2 = () =&gt; {
     let result = 0;
     result = func1(); // should I turn it into await func1()??
     console.log(result);  // log contains '0' instead of '1' or '2'
     return result;    // return as Promise but value inside is 0
  }
  
  </code></pre>
  <p>And what if I have a func3 which would call func2, should I turn func3 into async-await as well?</p>