fix: 에러 처리

main
Lim Jonguk 3 years ago
parent e3e2bf54b8
commit 486e87febc

@ -29,6 +29,8 @@ const verifyToken = (accessToken) => {
return false;
}
const decoded = jwtDecode(accessToken);
console.log(decoded);
/**
* 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)) {
setLocalStorage(ACCESS_TOKEN_NAME, accessToken);
const response = await axios.get('/api/v1/ctgy/user');
console.log(response);
const { userid, email, name } = response.data;
dispatch({
type: LOGIN,

@ -23,7 +23,7 @@ const dashboard = {
type: 'item',
url: '/dashboard/default',
icon: icons.IconDashboard,
breadcrumbs: true
breadcrumbs: false
},
{
id: 'analytics',
@ -31,7 +31,7 @@ const dashboard = {
type: 'item',
url: '/dashboard/analytics',
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, request, response, error) => {
if (error.isAxiosError) {
let errMsg = `시스템 에러~~~~~~~~~~~~`;
if (error.code === 'ECONNABORTED') errMsg = 'Server time out';
if (response && response.data) {
const errCode = response.data.code || response.data.status;
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({
icon: 'error',
title: 'Api Error',
html: errMsg,
html: `${errMsg} [ ${errCode} ]`,
// imageUrl:
timer: 5000
}).then((r) => r);
return;
}
if (response) {
const errCode = response.data.code;
const errMsg = response.data.error;
console.error(`${errCode}: ${errMsg}`);
console.error('=================================');
// Alert.error(`${errCode}: ${errMsg}`);
if (error.isAxiosError) {
let errMsg = `시스템 에러~~~~~~~~~~~~`;
if (error.code === 'ECONNABORTED') errMsg = 'Server time out';
Swal.fire({
icon: 'error',
title: 'Api Error',
html: `${errCode}: ${errMsg}`,
html: errMsg,
// imageUrl:
timer: 5000
}).then((r) => r);

Loading…
Cancel
Save