M
M
myskypesla2019-02-19 11:37:47
Vue.js
myskypesla, 2019-02-19 11:37:47

How to correctly write interceptor in axios?

Tell me the interceptor, at which I will be before making a request to the server, and it occurs in two versions, either during some action, or when moving along the routes. Accordingly, I need an interceptor that will request a new refresh_token and access on the server.
Now there is a problem in which a request is first sent, let's say, to receive a token -> the token changes -> then a request is sent to receive news with the old token, since the new token has not yet arrived -> then an error comes out that the token is invalid, which is logical.
Question: how to make it so that before any request, the refresh_token first fires and only then does the request go?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question