title: What is the proper syntax for axios post call to django rest-auth token in React JS?
body: <p>Currently, my code is communicating with my django-rest-auth api. It is getting the token, however, it is not authenicating the request. My backend shows 200 (username and password is correct). While my front end, reactjs is declaring wrong username or password (i created in else statement) and a 400 bad request error. </p>
  
  <pre><code> axios
        .post(
            'http://127.0.0.1:8000/rest-auth/login/',
            {
                  username: this.state.username,
                  password: this.state.password
            },
          //   { withCredentials: true }
            { isAuthenticated: true }
        )
            .then(response =&gt; {
                const token = response.data.key;
                if (localStorage.getItem(token)) {
                    console.log(token);
                    this.props.handleSucessfulAuth();
                } else {
                    this.setState({
                        errorMessage: 'Wrong username or password'
                    });
                    this.props.handleUnsuccessfulAuth();
                  //   console.log(token);
                }
  
            })
  
         .catch(error =&gt; {
             this.setState({
                 errorMessage: 'Authorization error occured',
                 error
             })
             this.props.handleUnsuccessfulAuth();
      });
  
  }
  </code></pre>
  
  <p>Now I have changed the top portion to the following:</p>
  
  <pre><code>handleSubmit(event) {
          event.preventDefault();
          axios.defaults.headers.common["Authorization"] = `Token ${this.props.token}`;
  
          axios
            .post(
                'http://127.0.0.1:8000/rest-auth/login/',
                {
                      username: this.state.username,
                      password: this.state.password
                },
              //   { withCredentials: true }
                { isAuthenticated: true }
            )
                .then(response =&gt; {
                    const token = response.data.key;
                    if (localStorage.setItem(token, 'token')) {
                        console.log(token);
                        this.props.handleSucessfulAuth();
                    } else {
                        this.setState({
                            errorMessage: 'Wrong username or password'
                        });
                        this.props.handleUnsuccessfulAuth();
                      //   console.log(token);
                    }
  
                })
  </code></pre>