Prevent 401 error browser console angular

Viewed 338

I have this problem, i have implemented a JWT token with refresh token options when the JWT token expire. When the token expires my serverless backend return a 401 and in this case with my angular interceptor i'll call the http API for refresh my jwt token and after this i call again the request ,http, without the user logout from his session. But the browser console show the 401 error and i want to prevent this one.

So how can i prevent the error in the console browser? I must return a different code instead of 401 like a 200 or there is another way?

Thank you

1 Answers

The 401 error in the browser console cannot be prevented. You are stuck with it! I would not recommend using a success code for a failure code! Everyone understands what 401 means. If you start returning the 226 status code or something equally irrelevant (for a 401) then you will get rid of the error in the console but you will also confuse everyone!

If you do decide to proceed down this crazy route then obviously you will need to handle 226's in your interceptor. My advice is, just put up with the red in the console :)

Related