title: react-redux redirect to other page after login
body: <p><code>action.js</code>:</p>
  
  <pre><code>export const login = creds =&gt; {
      console.log(`${url}/login`);
      const requestOptions = {
          method: "POST",
          headers: {
              Accept: "application/json",
              "Content-Type": "application/json"
          },
          body: creds
      };
  
      return function(dispatch) {
          dispatch({ type: LOGIN_REQUEST });
          function timer() {
              return fetch(`${url}/login`, requestOptions).then(response =&gt; {
                  if (!response.ok) {
                      console.log(response);
                      return response.json().then(json =&gt; {
                          var error = new Error(json.message);
                          error.response = response;
                          throw error;
                      });
                  } else {
                      console.log("3");
                      return response.json();
                  }
              }).then(user =&gt; {
                  if (user.message === "ok") {
                      localStorage.setItem("token", user.token);
                      dispatch({ type: LOGIN_SUCCESS, payload: user.token });
                      window.location.href = `${app}/dashboard`;
                  } else {
                      const error = user.message;
                      throw new Error(error);
                  }
              }).catch(function(error) {
                  dispatch(loginError(error));
              });
          }
          setTimeout(timer, 5000)
      }
  };
  </code></pre>
  
  <p>I am unable to redirect in a single-page manner to my dashboard, I searched a lot but I didn't get anything useful. I am using React Router v4. Can you please suggest whether I am doing this user login with JWT the right way or not.</p>