fix: 에러 처리

main
Lim Jonguk 3 years ago
parent e3e2bf54b8
commit 486e87febc

@ -29,6 +29,8 @@ const verifyToken = (accessToken) => {
return false; return false;
} }
const decoded = jwtDecode(accessToken); const decoded = jwtDecode(accessToken);
console.log(decoded);
/** /**
* Property 'exp' does not exist on type '<T = unknown>(token, options?: JwtDecodeOptions | undefined) => T'. * Property 'exp' does not exist on type '<T = unknown>(token, options?: JwtDecodeOptions | undefined) => T'.
*/ */
@ -60,6 +62,7 @@ export const JWTProvider = ({ children }) => {
if (accessToken && verifyToken(accessToken)) { if (accessToken && verifyToken(accessToken)) {
setLocalStorage(ACCESS_TOKEN_NAME, accessToken); setLocalStorage(ACCESS_TOKEN_NAME, accessToken);
const response = await axios.get('/api/v1/ctgy/user'); const response = await axios.get('/api/v1/ctgy/user');
console.log(response);
const { userid, email, name } = response.data; const { userid, email, name } = response.data;
dispatch({ dispatch({
type: LOGIN, type: LOGIN,

@ -23,7 +23,7 @@ const dashboard = {
type: 'item', type: 'item',
url: '/dashboard/default', url: '/dashboard/default',
icon: icons.IconDashboard, icon: icons.IconDashboard,
breadcrumbs: true breadcrumbs: false
}, },
{ {
id: 'analytics', id: 'analytics',
@ -31,7 +31,7 @@ const dashboard = {
type: 'item', type: 'item',
url: '/dashboard/analytics', url: '/dashboard/analytics',
icon: icons.IconDeviceAnalytics, icon: icons.IconDeviceAnalytics,
breadcrumbs: true breadcrumbs: false
} }
] ]
}; };

@ -26,30 +26,30 @@ const axiosService = axios.create({
*/ */
// const alertError = (config: AxiosRequestConfig, request: any, response: AxiosResponse, error: Error) => { // const alertError = (config: AxiosRequestConfig, request: any, response: AxiosResponse, error: Error) => {
const alertError = (config, request, response, error) => { const alertError = (config, request, response, error) => {
if (error.isAxiosError) { if (response && response.data) {
let errMsg = `시스템 에러~~~~~~~~~~~~`; const errCode = response.data.code || response.data.status;
if (error.code === 'ECONNABORTED') errMsg = 'Server time out'; const errMsg = response.data.code != '' && response.data.code != null ? response.data.message : response.data.error;
console.error(`${errCode}: ${errMsg}`);
console.error('=================================');
// Alert.error(`${errCode}: ${errMsg}`);
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Api Error', title: 'Api Error',
html: errMsg, html: `${errMsg} [ ${errCode} ]`,
// imageUrl: // imageUrl:
timer: 5000 timer: 5000
}).then((r) => r); }).then((r) => r);
return; return;
} }
if (response) { if (error.isAxiosError) {
const errCode = response.data.code; let errMsg = `시스템 에러~~~~~~~~~~~~`;
const errMsg = response.data.error; if (error.code === 'ECONNABORTED') errMsg = 'Server time out';
console.error(`${errCode}: ${errMsg}`);
console.error('=================================');
// Alert.error(`${errCode}: ${errMsg}`);
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Api Error', title: 'Api Error',
html: `${errCode}: ${errMsg}`, html: errMsg,
// imageUrl: // imageUrl:
timer: 5000 timer: 5000
}).then((r) => r); }).then((r) => r);

Loading…
Cancel
Save