title: How to I redirect after login while using jwt authentication
body: <p>I have a Node.js backend server which uses JWT for authentication. While building the frontend for the app when I send a login request and receive the token I store it in the localStorage of the browser, after that I want to redirect to the dashboard but the problem I am facing is that since the dashboard route is protected it requires the token but Js redirect method doesn't allow any headers. So, how should I be tackling this problem ?</p>
  
  <pre><code>const submit = document.getElementById("submit");
  
  if (!localStorage.getItem("token"))
      localStorage.setItem("token", "");
  
  submit.addEventListener('click' , (e) =&gt; {
     const email = document.getElementById("email").value;
     const password = document.getElementById("password").value;
     e.preventDefault();
     const data = {
        email,
        password
     }
     axios.post('/api/user/login', data)
        .then((res) =&gt; {
              document.getElementById('login_form').reset();
              console.log(res.data);
              if (res.data.success) {
                 localStorage.setItem("token", res.data.token);
                 document.window.location.href = '/organizer/dashboard';
              }
           })
        .catch((err) =&gt; {
           console.log(err);
           })
  });
  </code></pre>
  
  <p>The JSON received after a successful login request : </p>
  
  <pre><code>{
      "success": true,
      "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjViNTQzMWE1OTA0ZjkzMDQwOWM2OWU0NCIsIm5hbWUiOiJyYXNpayByYWoiLCJlbWFpbCI6ImZpc3J0QGdtYWlsLmNvbSIsImFjY190eXBlIjoib3JnYW5pc2VyIiwiaWF0IjoxNTMyMjQ4Mjc3LCJleHAiOjE1MzIyNTE4Nzd9.RHBMlVXXo-1YpwxnJbPdZ2VJ6Yt7aqTNJ3o6OzbXk4M"
  }
  </code></pre>