title: JavaScript - How to handle 404 error in fetch?
body: <p>When I call the request function passing a number which I know I will get a 404 error, I cant handle it, I dont know how to do it.</p>
  
  <pre><code>async request(number) {
      var request = "https://reqres.in/api/users/"+number;
  
      fetch(request, {method: "GET"})
      .then((response) =&gt; {
        return response.json(); 
      })
      .then((responseJson) =&gt; {
        this.setState({nombre:responseJson.data.first_name})
      })
      .catch((error) =&gt; {
        this.setState({nombre:error})
      }).done();
  }
  </code></pre>
  
  <p>Full code: <a href="https://codeshare.io/5wWo9p" rel="noreferrer">https://codeshare.io/5wWo9p</a></p>