0
1
Fork 0

perf: improve interceptor

This commit is contained in:
Javier Segarra 2024-08-19 12:38:33 +02:00
parent e47edb9827
commit f821b8689a
1 changed files with 2 additions and 8 deletions

View File

@ -21,7 +21,7 @@ const onRequestError = error => {
}; };
const onResponseError = error => { const onResponseError = error => {
let message = ''; let message = error.message;
const response = error.response; const response = error.response;
const responseData = response && response.data; const responseData = response && response.data;
@ -35,12 +35,6 @@ const onResponseError = error => {
return Promise.reject(error); return Promise.reject(error);
}; };
const jApiErrorInterceptor = error => {
if (error.message) {
notify(error.message, 'negative');
}
};
export default boot(({ app }) => { export default boot(({ app }) => {
const user = userStore(); const user = userStore();
function addToken(config) { function addToken(config) {
@ -53,7 +47,7 @@ export default boot(({ app }) => {
api.interceptors.response.use(response => response, onResponseError); api.interceptors.response.use(response => response, onResponseError);
jApi.use(addToken); jApi.use(addToken);
jApi.useErrorInterceptor(jApiErrorInterceptor); jApi.useErrorInterceptor(onResponseError);
// for use inside Vue files (Options API) through this.$axios and this.$api // for use inside Vue files (Options API) through this.$axios and this.$api