title: Unable to catch and log the Error response from an axios request
body: <p>I am having a axios request in my react application, for which I am following the <strong><a href="https://www.npmjs.com/package/axios" rel="noreferrer">axios npm docs.</a></strong> </p>
  
  <p>This is my axios request</p>
  
  <pre><code> axios.post(helper.getLoginApi(), data)
          .then((response) =&gt; {
              console.log(response);
  
              this.props.history.push(from.pathname)
          })
          .catch((error)=&gt; {
              console.log(error);
          })
  </code></pre>
  
  <p>I am able to successfully log the data on a successful request. However When I intentionally produce an error and try to console.log it, I don't get the result logged instead, I just see</p>
  
  <blockquote>
    <p>POST <a href="http://localhost:3000/login" rel="noreferrer">http://localhost:3000/login</a> 401 (Unauthorized) 
    :3000/login:1<br>
    Error: Request failed with status code 401 
    login.js:66 </p>
    
    <p>at createError (createError.js:16)</p>
    
    <p>at settle (settle.js:18)</p>
    
    <p>at XMLHttpRequest.handleLoad (xhr.js:77)</p>
  </blockquote>
  
  <p>However when I go to Network Tab in Chrome Console, I can see the below response returned. </p>
  
  <p><a href="https://i.stack.imgur.com/MO743.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MO743.png" alt="enter image description here"></a></p>
  
  <p>Thanks for help in advance .</p>