Why axios.interceptors executed twice.

Why did axios.interceptors execute it twice

 
 new Vue({
    router,
    store,
    created() {
      Vue.prototype.$http = axios;
      this.$http.interceptors.response.use(response => {
        console.log("-----")
                return response.data
            }, error => {
                if (error && error.response && error.response.status == "401") {
          this.$cookies.remove("userName");
          this.$cookies.remove("token");
          //router
          this.$router.options.routes = [];
                    this.$router.push({ path: "/login" });
                }
                return Promise.reject(error)
      });
      if (VueCookies.get("token")) {
        axios.defaults.headers["Authorization"] = VueCookies.get("token");
        store.dispatch("UpdateMenu");
      } else {
        this.$cookies.remove("userName");
        this.$cookies.remove("token");
        //router
        this.$router.options.routes = [];
        this.$router.push({ path: "/login" });
      }
    },
    render: h => h(App)
  }).$mount("-sharpapp");

printed two lines of "-". Axios.interceptors is not set elsewhere

Mar.20,2021

I also came across, preliminary discovery, due to the re-registration of this interceptor.


I have also encountered it now. The main reason for the skull pain data functions should return an object is that it can not find the reason why it is triggered twice

Menu