-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
import { EpigramType } from '@/schema/todayepigram'; | ||
import { AxiosError } from 'axios'; | ||
import type { EpigramType } from '@/schema/todayepigram'; | ||
import httpClient from './index'; | ||
|
||
const getTodayEpigram = async (): Promise<EpigramType> => { | ||
try { | ||
const response = await httpClient.get<EpigramType>('/epigrams/today'); | ||
return response.data; | ||
} catch (error) { | ||
if (error instanceof AxiosError) { | ||
if (error.response) { | ||
throw new Error('에피그램 조회 요청 처리 중 문제가 발생했습니다.'); | ||
} else if (error.request) { | ||
throw new Error('서버 응답을 받지 못했습니다. 잠시 후 다시 시도해 주세요.'); | ||
} else { | ||
throw new Error('에피그램 조회 요청을 처리하는 동안 문제가 발생했습니다.'); | ||
} | ||
} else { | ||
throw new Error('알 수 없는 오류가 발생했습니다.'); | ||
} | ||
} | ||
const response = await httpClient.get('/epigrams/today'); | ||
return response.data; | ||
}; | ||
|
||
export default getTodayEpigram; |