title: Difference between Fetch and Axios
body: <p>can somebody explain to me why when I am using fetch and accessed my nodejs api - it is authorized but when I tried using axios to access my api - it is unauthorized.</p>
  
  <p>This is the code I am using in fetch (It came from tutorial: <a href="https://medium.com/@alexanderleon/implement-social-authentication-with-react-restful-api-9b44f4714fa" rel="nofollow noreferrer">https://medium.com/@alexanderleon/implement-social-authentication-with-react-restful-api-9b44f4714fa</a>) Bec I am studying his way of authenticating using passport-facebook-token.</p>
  
  <p>(client -->(login fbsdk)--> fb --> (access token)--> client -->(pass access token)--> nodejs api --> (get credentials) --> passport-fb-token --> (send credentials) --> nodejs api --> (credentials)--> client)</p>
  
  <pre><code>const tokenBlob = new Blob([JSON.stringify({access_token: response.accessToken}, null, 2)], {type : 'application/json'});
      const options = {
          method: 'POST',
          body: tokenBlob,
          mode: 'cors',
          cache: 'default'
      };
      fetch('http://localhost:4000/api/v1/auth/facebook', options).then(r =&gt; {
          const token = r.headers.get('x-auth-token');
          r.json().then(user =&gt; {
              if (token) {
                  this.setState({isAuthenticated: true, user, token})
              }
          });
      })
  </code></pre>
  
  <p>This is the code of my axios</p>
  
  <pre><code>axios({
        method: 'post',
        url: 'http://localhost:4000/api/v1/auth/facebook',
        headers: {
          'Access-Control-Allow-Origin': '*',
        },
        data: {
          access_token: response.access_token
        }
    })
    .then((res) =&gt; console.log(res))
    .catch((err) =&gt; console.log(err));
  </code></pre>