Answer the question
In order to leave comments, you need to log in
How to implement token refresh on Nuxt/Vue?
I am making a site on Nuxt, if everything is clear with API authorization, we get a token and store it, then what about the refresh token? Suppose we have a date when the main token stops working and the time has come to update it, how to check this? Check token date via setInterval? Or through each page transition through beforeEach?
Answer the question
In order to leave comments, you need to log in
I did it through axios and the general handler, in the case of a non-working token, sent an error like 405 (for example). At the front, this error was set by the action of sending a refresh token, if it was erroneously thrown out of the system. If ok, then I updated the access token and made the request again.
https://axios.nuxtjs.org/extend
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question