title: JS Axios - how to get response body in event of error?
body: <p>I want to be able to get the response body back from an Axios error catch.</p>
  
  <p>I am using axios v0.18.0. </p>
  
  <p>My axios code looks like this:</p>
  
  <pre><code>let service = axios.create({
                  baseURL: "https://baseUrl.azurewebsites.net",
                  responseType: "json"
              });
  
          service.defaults.headers.common['authorization'] = `Bearer ${token}`;
  
          service.post("/api/method", params).then(result =&gt; {
              console.log('success',result);
          }).catch(error=&gt;{
              console.log('error');
              console.log(error);
          });
  </code></pre>
  
  <p>My API call is returning a 400 error as I expected, given my inputs. So I am hitting the catch block. However I'm not able to retrieve the error message that's returned by the API call.</p>
  
  <p>I've tried doing a console.out(error.response.data), but this returns null.</p>
  
  <p>I've verified using Postman that the API call <em>does</em> return an error message in the response body, so the API isn't the problem.</p>
  
  <p>What am I missing?</p>