Closed tomekxoxo closed 5 months ago
Hi, thanks for reporting @tomekxoxo I understand why this looks strange, and should perhaps be written in a different way. But I think there is something else going on here.
Reacts 'useState' is asynchronous, so if I access the variable right after its set, in an synchronous code block, I will in fact be referring to the old value.
Could be that the reliance on this causes issues if you are doing something funky by intercepting requests.
If token
was empty, you should never be redirected, and therefore never get a 401.
If you do get redirected, but no token in the request, that would be very strange.
Can you provide full authConfig
, console log, and network requests for further debugging?
I deliberately cut out a token from a network request to receive 401. Could that be an issue?
I think I found an issue in my interceptor, sorry for false alarm
Yeah i didn't eject interceptors when data changes :)
I want to logout from my application in Axios interceptor when i receive 401 code. It works with setTimeout set to 5seconds, but it dose not without it. On the screenshot token is empty in if statement. Also why do you clear token before checking if it exist? I use: "axios": "^1.3.2", "react-oauth2-code-pkce": "^1.20.0",
Screenshots
The expected behavior
Token is not cleared before checking if it exist to be able to logout