Don't show error dialog every error

This commit is contained in:
rijkvanzanten
2020-11-05 16:20:20 -05:00
parent 4130337f7a
commit a2871bca73

View File

@@ -1,8 +1,7 @@
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
import { useNotificationsStore, useRequestsStore } from '@/stores/';
import { useRequestsStore } from '@/stores/';
import { LogoutReason, logout, refresh } from '@/auth';
import getRootPath from '@/utils/get-root-path';
import i18n from './lang';
const api = axios.create({
baseURL: getRootPath(),
@@ -41,7 +40,6 @@ export const onResponse = (response: AxiosResponse | Response) => {
};
export const onError = async (error: RequestError) => {
const notificationsStore = useNotificationsStore();
const requestsStore = useRequestsStore();
const id = (error.response.config as RequestConfig).id;
requestsStore.endRequest(id);
@@ -54,7 +52,6 @@ export const onError = async (error: RequestError) => {
const status = error.response?.status;
/* istanbul ignore next */
const code = error.response?.data?.errors?.[0]?.extensions?.code;
const message = error.response?.data?.errors?.[0]?.message || undefined;
if (
status === 401 &&
@@ -82,13 +79,6 @@ export const onError = async (error: RequestError) => {
}
}
notificationsStore.add({
title: i18n.t(`errors.${code}`),
text: message,
type: 'error',
dialog: true,
});
return Promise.reject(error);
};