mirror of
https://github.com/directus/directus.git
synced 2026-01-23 04:58:00 -05:00
Don't show error dialog every error
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user