Skip to content

Commit

Permalink
fix: 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjin-dev committed Jan 10, 2024
1 parent ee2cb45 commit c1dd630
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/api/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const instance = axios.create({
headers: { 'content-type': 'application/json' },
});

type BaroError = {
interface BaroErrorType {
status?: number;
message?: string;
};
}

instance.interceptors.response.use(
(response: AxiosResponse) => {
Expand All @@ -18,18 +18,21 @@ instance.interceptors.response.use(
(error: AxiosError<Error>) => {
// Network Error 발생 캐치
if (!error.response) {
return Promise.reject<BaroError>({
return Promise.reject<BaroErrorType>({
status: 408,
message: '현재 네트워크 상태가 불안정합니다. 잠시후 다시 시도해주세요',
});
}

// 서버 에러 캐치
if (error.status > 500) {
return Promise.reject<BaroError>({ status: error.status, message: '' });
return Promise.reject<BaroErrorType>({
status: error.status,
message: '',
});
}

return Promise.reject<BaroError>(error);
return Promise.reject<BaroErrorType>(error);
},
);

Expand Down

0 comments on commit c1dd630

Please sign in to comment.