title: Best way to check status code of http response?
body: <p>The question is: what is best way to check status code when get http response?
  for example</p>
  
  <pre><code>fetch('https://stackoverflow.com/').then((response)=&gt;{
      if (response.status &gt;= 400) {
          //handle unsuccessful request ...
      }
  
      // or 
      if (response.status == 200) { 
          // status ok 
      }
  
  });
  </code></pre>
  
  <p>However, the statements have magic number. e.g. 200 or 400.
  Is there best practice to avoid magic number?</p>