title: get response.status in .then in Java Script
body: <p>I tried to check if the status of my request is 200 (OK), but I do not know how to do these things together because the first and second <code>.then</code>, are not "like each other":</p>
  
  <pre class="lang-js prettyprint-override"><code>function f(path) {
      await fetch(path)
              .then(response =&gt; {
                  // console.log(response.status);
                  if (response.status != 200) {
                      throw response.status;
                  } else {
                      // do something
                  }
              })
              .then(response =&gt; response.json())
              .then(...method for the response.json()...)
              .catch(error =&gt; {
                  // print some error message
              }
  }
  </code></pre>
  
  <ul>
  <li>The second then failed and returned error.</li>
  </ul>
  
  <p>I have a problem when I throw that.</p>
  
  <p>It prints to the error to the console (when I check by changing the path to wrong path and I want to see if I treat errors).</p>
  
  <p>what can I do?</p>