title: How to post request login to get into dashboard . and save the token in react js
body: <p>I have a task to post request to api , basicly i always use json fake server to get username and password. but for this task i have to post request login with axios post. and headers application/json and body username,password. and define client id in body so, we just type username and password in form login but client id already define in body . and the problem i already try to post request but always getting error, and i wonder how to save the q / token before i get into dashboard. thank you </p>
  
  <p>login.js</p>
  
  <pre><code>class Login extends React.Component {
      constructor(props) {
        super(props);
        const token = localStorage.getItem("token");
  
        let isLogedIn = true
        if (token === null) {
            isLogedIn = false
        }
  
        this.state = {
            post : [],
            isLogedIn,
            id : '',
            username : '',
            password: '', 
        }
  
        this.handleForm = this.handleForm.bind(this);
        this.submitLogin = this.submitLogin.bind(this);
        this.handleSubmit = this.handleSubmit.bind(this);
      }
  
      handleForm  = (e) =&gt; { 
        this.setState ({
           [e.target.name] : e.target.value
        })
      }
  
  handleSubmit  () {
  
        const data = JSON.stringify({
          clientId : "authService",  
          clientSecret : "123",
          username: this.state.username,
          password: this.state.password 
        })
  
        const headers = {
          'Content-Type': 'application/json',
        }
  
        axios.post('http://10.50.51.21:8062/token', data, {
              headers: headers
  
          }
        )
  
  
        .then ((response) =&gt; {
          localStorage.setItem("token","this is token that i save before i get into dashboard")
          console.log(response)
          this.setState ({
            isLogedIn : true
          })
        })
  
        .catch (err =&gt; {
          console.log("Error : " ,err )
        })
        console.log(data);
      }
  </code></pre>
  
  <p>thankyou, please tell me what should i do. thank you very much to helping me</p>