fix: notification status api ignore 50x error

This commit is contained in:
shuai 2023-03-29 17:19:43 +08:00
parent f41a2ac761
commit 7b55f28993
2 changed files with 7 additions and 2 deletions

View File

@ -34,7 +34,7 @@ export const useQueryNotificationStatus = () => {
return useSWR<Type.NotificationStatus>(
tryLoggedAndActivated().ok ? apiUrl : null,
request.instance.get,
(url) => request.get(url, { ignoreError: '50X' }),
{
refreshInterval: 3000,
},

View File

@ -19,6 +19,7 @@ const baseConfig = {
interface ApiConfig extends AxiosRequestConfig {
// Configure whether to allow takeover of 404 errors
allow404?: boolean;
ignoreError?: '403' | '50X';
// Configure whether to pass errors directly
passingError?: boolean;
}
@ -169,7 +170,11 @@ class Request {
if (isIgnoredPath(IGNORE_PATH_LIST)) {
return Promise.reject(false);
}
errorCodeStore.getState().update('50X');
if (error.config?.ignoreError !== '50X') {
errorCodeStore.getState().update('50X');
}
console.error(
`Request failed with status code ${status}, ${msg || ''}`,
);