Skip to content

Commit

Permalink
♻️ Refactor : 맞춤형 추천 서버 안될 시 재요청 막도록 개선
Browse files Browse the repository at this point in the history
♻️ Refactor : 맞춤형 추천 서버 안될 시 재요청 막도록 개선
  • Loading branch information
eunjju2 authored Jan 17, 2025
2 parents 7becec3 + b340d2d commit 5ceccdd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pages/MainPage/hooks/useGetWorkplaceData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MapPosition,
NowPosition,
} from '@typings/types';
import { AxiosError } from 'axios';

export const useGetWorkplaceData = (
nowPosition: NowPosition,
Expand All @@ -31,10 +32,20 @@ export const useGetRecommendData = (
isUser: boolean,
activeTab: string,
) => {
const { data, isLoading, isError } = useQuery<GetPositionWorkPlaceData[]>({
const { data, isLoading, isError } = useQuery<
GetPositionWorkPlaceData[],
AxiosError
>({
queryKey: ['recommendWorkPlace', isLogin, isUser],
queryFn: () => getRecommendWorkPlace(),
enabled: isLogin && isUser && activeTab !== '주변 스터디룸',
retry: (failureCount, error: AxiosError) => {
// 503 에러 발생 시 재요청 금지
if (error.response?.status === 503) {
return false;
}
return failureCount < 3;
},
});

return {
Expand Down

0 comments on commit 5ceccdd

Please sign in to comment.