About the question prompted by iview Message many times

for example, when you first enter a page, there are 3 requests, 3 requests do not need to be sequenced, and token verification is done. If token expires, Message will prompt 3 times, and then jump to the login page. If I just want to prompt once, is there a better solution?

I"ve tried to wait for a request to succeed, and then do callBack processing, which doesn"t feel particularly good.

May.30,2022

1, you can choose anti-shake , delay processing token verification.
2. Add a global variable (or vuex) to verify whether the tag has been verified by token, and if so, do not remind


Building owner, you can borrow cancel token provided by axios . Paste the code of the specific implementation:

+ const CancelToken = axios.CancelToken;
+ const pending = [];

service.interceptors.response.use(
    response=>{
        const res=response.data;
        return response.data;
    },err=>{
        console.log(err);
        let errCode=err.response.data.errCode;
        let errMsg=err.response.data.errMsg;
        if(errCode===500&&errMsg=='Invalid token'){
+        // :
+        while (pending.length > 0) {
+          pending.pop()('');
+         }
            ...
            
        }
        else if(errCode===500&&errMsg=='No authority'){
        // :
+        while (pending.length > 0) {
+          pending.pop()('');
+         }
            ...
        }
    }
)

+ // axios 
+ const defaultConfig = {}

+ defaultConfig.cancelToken = new CancelToken(function executor(c) {
+    // An executor function receives a cancel function as a parameter
+    pending.push(c);
+  });

axios(defaultConfig);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bca3c6-309e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bca3c6-309e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?