title: Same request using Axios
body: <p>I was consuming an api using XHR, but the same request does not work using axios.</p>
  
  <p><strong>With XHR:</strong></p>
  
  <pre><code>var data = JSON.stringify(false);
  var xhr = new XMLHttpRequest();
  xhr.withCredentials = true;
  xhr.open("POST", "api/url");
  xhr.send(data);
  xhr.addEventListener("readystatechange", function () {
    if (this.readyState === this.DONE) {
      console.log(this.responseText);
    }
  });
  </code></pre>
  
  <p><strong>With Axios:</strong></p>
  
  <pre><code>axios({
    method: 'post',
    url: 'api/url',
    data: JSON.stringify(false),
    withCredentials: true
    })
    .then(function (response) {
      console.log(response);
    })
    .catch(function (error) {
      console.log(error);
    });
  </code></pre>
  
  <p><strong>Error is</strong></p>
  
  <blockquote>
    <p>"Response to preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource."</p>
  </blockquote>
  
  <p>Response Headers on XHR</p>
  
  <ul>
  <li>HTTP/1.1 200 OK </li>
  <li>Accept-Ranges: bytes</li>
  <li>Accept-Ranges: bytes</li>
  <li>Access-Control-Allow-Credentials: true</li>
  <li>Access-Control-Allow-Origin:<a href="http://localhost:8000" rel="nofollow noreferrer">http://localhost:8000</a></li>
  <li>Age: 0</li>
  <li>Cache-Control: no-cache, no-store, max-age=0, must-revalidate</li>
  <li>Content-Type: application/json;charset=UTF-8</li>
  <li>Date: Tue, 26 Dec 2017 13:50:01 GMT</li>
  <li>Expires: 0</li>
  <li>Pragma: no-cache</li>
  <li>Vary: Origin</li>
  </ul>
  
  <p>Response Headers on Axios:</p>
  
  <ul>
  <li>HTTP/1.1 404 Not Found</li>
  <li>Accept-Ranges: bytes</li>
  <li>Age: 0</li>
  <li>Content-Type: application/json; charset=utf-8</li>
  <li>Date: Tue, 26 Dec 2017 14:01:26 GMT</li>
  </ul>