title: How to redirect login page to dashboard using ReactJS?
body: <p>I want when I submit the email and the password to login, it will be redirected to the dashboard, my code is below :</p>
  <pre><code>     handleClick(event){
      
      var payload={
        &quot;email&quot;:this.state.email,
          &quot;password&quot;:this.state.password
      }
      axios({
            method: 'post',
            url: '/app/login/',
            data: payload,
            withCredentials: true,
            headers: {
              'Access-Control-Allow-Origin': '*',
              'Content-Type': 'application/json',
              'Accept': 'application/json',
            }
          })
     
     .then(function (response) {
       console.log(response);
       if(response.data.code == 200){
            response.redirect('http://localhost:5000/#/dashboard');
  
       }
       else if(response.data.code == 204){
         swal(&quot;Erreur !&quot;, &quot;Vérifiez vos champs SVP !&quot;, &quot;error&quot;);
        
       }
       else{
         swal(&quot;Erreur !&quot;, &quot;Username inexistant !&quot;, &quot;error&quot;);
        
       }
     })
    }
  </code></pre>
  <p>My route :</p>
  <pre><code>import React from 'react';
  import Loadable from 'react-loadable'
  const Dashboard = Loadable({
    loader: () =&gt;
      import ('./views/Dashboard'),
    loading: Loading,
  });
  const routes = [
  { path: '/dashboard', name: 'Dashboard', component: Dashboard }]
  </code></pre>
  <p>When I run it, I get :
  <a href="https://i.stack.imgur.com/MaKD1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MaKD1.png" alt="enter image description here" /></a></p>
  <p>How can I fix that please ?</p>