How the axios interceptor does not intercept when the condition is true

// 
axios.interceptors.request.use(function (config){
if (){
    
  }
 // 
 return config;
 }, function (error){
 // 
 return Promise.reject(error);
 });

if (condition) {

}

how should this paragraph be written in order to jump out of the current interceptor and deal with it only when the conditions do not meet

Jul.06,2021

when you jump out of the current interceptor, you should write the if condition outside the axios.interceptors and the intercept configuration item inside. Are you mistaken


you can write if (! Condition) {intercept.}


meet the conditions to enter, directly return


write like this?

if (){
    
} else {
    // 
    axios.interceptors.request.use(function (config){
        // 
        return config;
    }, function (error){
        // 
        return Promise.reject(error);
    });
}

does it feel so simple?

Menu