How to add the axios request interceptor after the end of the http request

you need to request the backend to obtain the token, using the interceptor to bring the token by default.

instance.interceptors.request.use(function (config) {
    //config
    getToken()
        .then((data) => {
            config.headers.Authorization = data;
           
        })
         return config;
   console.log(config)

});
The

getToken function puts token, back through promise, but return does not go out. How should token be set

Aug.17,2021

instance.interceptors.request.use(config => {
      const token = getToken()
      if (token) {
        config.headers.token = token
      }
      return config
    }, error => {
      return Promise.reject(error)
    })
Menu