forked from verdnatura/hedera-web
perf: improve interceptor
This commit is contained in:
parent
e47edb9827
commit
f821b8689a
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue