title: Axios POST to Mailchimp API: HTTP Authentication not working
body: <p>I'm trying to make an axios request to my mailchimp account. But it does not seem to be working. I cannot get it to authorize me - what am I doing wrong here? I have been following <a href="https://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/" rel="noreferrer">this tutorial:</a> which says:</p>
  
  <blockquote>
    <p>There are 2 authentication methods for the API: HTTP Basic
    authentication and OAuth2. The easiest way to authenticate is using
    HTTP Basic authentication. Enter any string as your username and
    supply your API Key as the password. Your HTTP client library should
    have built-in support for Basic authentication, but here’s a quick
    example that shows how to authenticate with the --user option in curl:</p>
  </blockquote>
  
  <pre><code>curl --request GET \
  --url 'https://&lt;dc&gt;.api.mailchimp.com/3.0/' \
  --user 'anystring:&lt;your_apikey&gt;'
  </code></pre>
  
  <p>So I implemented:</p>
  
  <pre><code>axios.post('https://us1.api.mailchimp.com/3.0/lists/xad81287/members/', {
        auth:
          {
            url: 'https://us1.api.mailchimp.com/3.0',
            user: 'blabla:11231h23123j14bhj1b23j12-us1' //this is my API key
          },
        firstName: 'Fred',
        lastName: 'Flintstone'
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
  </code></pre>
  
  <p>(I have changed the API things and list names here randomly)</p>
  
  <p>Error I'm getting:</p>
  
  <blockquote>
    <p>OPTIONS <a href="https://us1.api.mailchimp.com/3.0/lists/afafaf/members/" rel="noreferrer">https://us1.api.mailchimp.com/3.0/lists/afafaf/members/</a>
    401 (Unauthorized) dispatchXhrRequest @ xhr.js:178 xhrAdapter @
    xhr.js:12 dispatchRequest @ dispatchRequest.js:59 Promise resolved
    (async) request @ Axios.js:51 Axios.(anonymous function) @ Axios.js:71
    <a href="https://us1.api.mailchimp.com/3.0/lists/afafaf/members/" rel="noreferrer">https://us1.api.mailchimp.com/3.0/lists/afafaf/members/</a>: Response
    to preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:8000" rel="noreferrer">http://localhost:8000</a>' is therefore not allowed
    access. The response had HTTP status code 401.</p>
  </blockquote>