From f821b8689a9f589ecaf51bcf26b37502ec002e77 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 19 Aug 2024 12:38:33 +0200 Subject: [PATCH] perf: improve interceptor --- src/boot/axios.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/boot/axios.js b/src/boot/axios.js index 039d6235..8902e070 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -21,7 +21,7 @@ const onRequestError = error => { }; const onResponseError = error => { - let message = ''; + let message = error.message; const response = error.response; const responseData = response && response.data; @@ -35,12 +35,6 @@ const onResponseError = error => { return Promise.reject(error); }; -const jApiErrorInterceptor = error => { - if (error.message) { - notify(error.message, 'negative'); - } -}; - export default boot(({ app }) => { const user = userStore(); function addToken(config) { @@ -53,7 +47,7 @@ export default boot(({ app }) => { api.interceptors.response.use(response => response, onResponseError); jApi.use(addToken); - jApi.useErrorInterceptor(jApiErrorInterceptor); + jApi.useErrorInterceptor(onResponseError); // for use inside Vue files (Options API) through this.$axios and this.$api