-1
I’m making an application and was creating a Privaterouter.
Since I am using a Fake API (hai-server) it generates me a token on login and I can block calls from some routes if I do not pass this token, there is no verifyToken, then I had the idea of validating the Privaterouter through a call in one of these Urls and giving me success I changed a variable or state to validate the component as in the image.
Only, React because it is asynchronous it renders the Return before returning the call, I tried it with useEffect and useEffect but without success.
Someone would have an idea, I know there are other methods but this was what I imagined for the type of Api I’m using to have more security after they login..