title: How to make an axios.post request with Basic Authentification using React.Js?
body: <p>I'm making an axios.post request with React.Js, Redux and Basic Auth, and i found this error.
  How can i fix it please ?</p>
  <p>I'm using: Front (React.Js), Back (SpringBoot), Data Base (MySQL)</p>
  <p>This is my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const allDev = []
  export const createGps = (gpsDevice) =&gt; {
    let uri = "http://62.171.157.49:8081/api/devices";
              
    let h = new Headers();
    h.append('Accept', 'application/json');
    let encoded = window.btoa('yahya.mess95@gmail.com:Yahya@2027');
    let auth = `Basic ${  encoded}`;
    h.append('Authorization', auth );
    console.log( auth );
    
    let req = new Request(
      uri, 
      gpsDevice,
      {
        method: 'POST',
        headers: h,
        credentials: 'include'
      }
    );
      return (dispatch) =&gt; {
        axios.post(req)
        .then( (response)=&gt;{
          console.log(response)
            if(response.ok){
                dispatch(notifAdd())
                console.log(response.json())
                return response.json();
            }
            throw new Error('BAD HTTP stuff');
            
        })
        .then( (jsonData) =&gt;{
            console.log(jsonData);
            JSON.stringify(jsonData, null, 4);
              return {
                ...gpsDevice,
                allDev: [...allDev, {...gpsDevice}]
              }
        })
        .catch((err) =&gt; console.log("error adding dev: ", err))
      }
  }</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/kYVmb.png" rel="nofollow noreferrer">enter image description here</a></p>