title: Catch UnhandledPromiseRejectionWarning during fetch
body: <p>I have a code:</p>
  
  <pre><code>function () {
    return new Promise((resolve, reject) =&gt; {
      try {
        fetch(URL, { method: METHOD, body: BODY })
          .then((res) =&gt; res.json())
          .then((json) =&gt; {
            resolve(json);
          })
          .catch((res) =&gt; {
            reject(res);
          })
      } catch (exception) {
        reject(exception);
      }
    });
  }
  </code></pre>
  
  <p>When server responses not with json I've got</p>
  
  <blockquote>
    <p>UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().</p>
  </blockquote>
  
  <p>I know that try-catch do not catch async throws.</p>
  
  <p>I have read </p>
  
  <p><a href="https://stackoverflow.com/questions/46571730/cannot-catch-unhandledpromiserejectionwarning-in-promise">Cannot catch UnhandledPromiseRejectionWarning in promise</a>,</p>
  
  <p><a href="https://stackoverflow.com/questions/50963104/try-catch-unable-to-catch-unhandledpromiserejectionwarning">Try Catch unable to catch UnhandledPromiseRejectionWarning</a>,</p>
  
  <p><a href="https://stackoverflow.com/questions/46738830/unhandledpromiserejectionwarning-error-even-when-catch-is-present">“UnhandledPromiseRejectionWarning” error even when catch is present</a></p>
  
  <p>but there is no answer for my question.</p>