🐛 fix: exception handling

This commit is contained in:
Martial BE
2024-01-13 02:46:32 +08:00
committed by Buer
parent 3b46e4ca16
commit 290523b675
25 changed files with 754 additions and 538 deletions

View File

@@ -13,7 +13,7 @@ API.interceptors.response.use(
if (error.response?.status === 401) {
localStorage.removeItem('user');
store.dispatch({ type: LOGIN, payload: null });
window.location.href = '/login';
// window.location.href = '/login';
}
if (error.response?.data?.message) {

View File

@@ -70,12 +70,16 @@ export function showInfo(message) {
}
export async function getOAuthState() {
const res = await API.get('/api/oauth/state');
const { success, message, data } = res.data;
if (success) {
return data;
} else {
showError(message);
try {
const res = await API.get('/api/oauth/state');
const { success, message, data } = res.data;
if (success) {
return data;
} else {
showError(message);
return '';
}
} catch (error) {
return '';
}
}