Next.js Discord

Discord Forum

api request

Unanswered
Alaska pollock posted this in #help-forum
Open in Discord
Alaska pollockOP
Yo, So when a user try to access the /panel (which is the users dashboard/panel) and if the jwt token theyre using is invalid/expired it redirects them to the /login route. Well,
c++
const fetchUserData = () => {
      axios
        .get("http://localhost:3001/profile", { withCredentials: true })
        .then((response) => {
          setUserData(response.data.user);
        })
        .catch((error) => {
          redirectToLogin();
        });
    };


The problem is it will peek the content first. Then when the request is sent then it will redirect them, Is there a fix for this?

2 Replies

So you're facing error like "Network Errors"

Just coz you usually localhost address?
@Alι_ Aryαɴ So you're facing error like "Network Errors" Just coz you usually localhost address?
Alaska pollockOP
Nope, Im not. Could you please read the message i sent like really read it. If its un-clear just tell me.