title: logging errors in async functions
body: <p>I have this code:</p>
  
  <pre><code>async function getURL() {
     try {
         await fetch("http://www.blah.com");
         return 0;
     } catch (err) {
         return err;
     }
  }
  
  getURL().then( result =&gt; {
      if (result === 0) console.log("success");
      else console.log(result);
  });
  </code></pre>
  
  <p>The fetch will fail and the error is logged to the console.  How do I rework the code so it uses async and try/catch everywhere?  That is, I'm looking to avoid doing getURL().then for the sake of consistency. </p>
  
  <p>EDIT:</p>
  
  <p>For those downvoting me, <code>await getURL()</code> won't work as it's invalid syntax.  </p>
  
  <p>EDIT2:</p>
  
  <p>Tried this but it didn't catch the error:</p>
  
  <pre><code>async function getURL() {
      return await fetch("http://www.blah.com");
  }
  
  let result = async function() {return await getURL();}
  
  try {
      result();
  } catch (e) {
      console.log(e);
  }
  </code></pre>