Answer the question
In order to leave comments, you need to log in
Checking a token?
Hello, how can I check the token for "liveness" before each request to the API?
During authorization, only access & refresh tokens come, that is, the lifetime does not come
. Found that you can check the token when the application is initialized
created: function () {
axios.interceptors.response.use(function (response) {
return response;
}, function (err) {
if (err.response?.status === 401 && err.response?.config && !err.response?.config.__isRetryRequest) {
store.dispatch(LOGOUT)
}
throw err;
});
}
Answer the question
In order to leave comments, you need to log in
When you receive it is the time of its creation. Next, before sending, find the difference between the current time and the time it was created.
Or you can not check the lifetime of the token . Just if you get an error in the server response -
if (err.response.status === token expired ....
- you get a new one using a refresh token.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question