|
@@ -15,8 +15,8 @@ let config = {
|
|
|
withCredentials: true // Check cross-site Access-Control
|
|
|
};
|
|
|
|
|
|
-const _axios = axios.create(config);
|
|
|
-const _axiosWithoutResponseInterceptors = axios.create(config);
|
|
|
+const _$httpWith500Msg = axios.create(config);
|
|
|
+const _$http = axios.create(config); // no auto 500 error UI
|
|
|
|
|
|
/**
|
|
|
* A. token lifecycle
|
|
@@ -37,7 +37,7 @@ function getRootOrgId() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-_axios.interceptors.request.use(
|
|
|
+_$httpWith500Msg.interceptors.request.use(
|
|
|
function(config) {
|
|
|
// Do something before request is sent
|
|
|
if (
|
|
@@ -84,7 +84,8 @@ _axios.interceptors.request.use(
|
|
|
}
|
|
|
);
|
|
|
|
|
|
-_axiosWithoutResponseInterceptors.interceptors.request.use(
|
|
|
+_$http.interceptors.request.use(
|
|
|
+ // no auto 500 error UI
|
|
|
function(config) {
|
|
|
// Do something before request is sent
|
|
|
if (config.url.includes("/login") === false) {
|
|
@@ -124,7 +125,7 @@ _axiosWithoutResponseInterceptors.interceptors.request.use(
|
|
|
);
|
|
|
|
|
|
// Add a response interceptor
|
|
|
-_axios.interceptors.response.use(
|
|
|
+_$httpWith500Msg.interceptors.response.use(
|
|
|
response => {
|
|
|
return response;
|
|
|
},
|
|
@@ -199,7 +200,8 @@ _axios.interceptors.response.use(
|
|
|
);
|
|
|
|
|
|
// Add a response interceptor
|
|
|
-_axiosWithoutResponseInterceptors.interceptors.response.use(
|
|
|
+_$http.interceptors.response.use(
|
|
|
+ // no auto 500 error UI
|
|
|
response => {
|
|
|
return response;
|
|
|
},
|
|
@@ -246,19 +248,33 @@ _axiosWithoutResponseInterceptors.interceptors.response.use(
|
|
|
);
|
|
|
|
|
|
Plugin.install = function(Vue) {
|
|
|
- Vue.$http = _axiosWithoutResponseInterceptors;
|
|
|
+ Vue.$http = _$http; // no auto 500 error UI
|
|
|
Object.defineProperties(Vue.prototype, {
|
|
|
$http: {
|
|
|
get() {
|
|
|
- return _axiosWithoutResponseInterceptors;
|
|
|
+ return _$http; // no auto 500 error UI
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- Vue.$httpWithMsg = _axios;
|
|
|
+
|
|
|
+ Vue.$httpWithMsg = _$httpWith500Msg;
|
|
|
Object.defineProperties(Vue.prototype, {
|
|
|
$httpWithMsg: {
|
|
|
get() {
|
|
|
- return _axios;
|
|
|
+ return _$httpWith500Msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // for below request
|
|
|
+ // config.url.includes("/api/ecs_ques/paper/") === false &&
|
|
|
+ // config.url.includes("/api/ecs_ques/questionAudio") === false
|
|
|
+ const _a = axios.create(config);
|
|
|
+ Vue.$httpWithoutAuth = _a;
|
|
|
+ Object.defineProperties(Vue.prototype, {
|
|
|
+ $httpWithoutAuth: {
|
|
|
+ get() {
|
|
|
+ return _a;
|
|
|
}
|
|
|
}
|
|
|
});
|