title: Uncaught (in promise) Error: Request failed with status code 400
body: <p>I was testing my code to see what would happen if I tried to register an already registered user and when I did that I got the error in the title with the expected <em>error status code</em>, however, I do have a catch statement so I'm not sure why the error is not being caught.</p>
  <p>This is the state of the class:</p>
  <pre><code>state = {
      data: { username: &quot;&quot;, password: &quot;&quot;, name: &quot;&quot; },
      errors: {},
    };
  </code></pre>
  <p>This is my code:</p>
  <pre><code>doSubmit = async () =&gt; {
      try {
        await userService.register(this.state.data);
      } catch (error) {
        if (error.response &amp;&amp; error.response.status === 400) {
          const errors = { ...this.state.errors };
          errors.username = error.response.data;
          this.setState({ errors });
        }
      }
    };
  </code></pre>
  <pre><code>export function register(user) {
    http.post(apiEndpoint, {
      email: user.username,
      password: user.password,
      name: user.name,
    });
  }
  </code></pre>
  <p>Any help would be appreciated!</p>