Skip to content

Commit 8ca4105

Browse files
committed
refac: type-name & error-handling(500page) about getSponsorData
1 parent 274733e commit 8ca4105

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

frontend/pages/api/sponsor.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@ import { IContents } from '../../interfaces/IContents'
33
import { IApiContents } from '../../interfaces/api/IApiContents'
44
import { API_SERVER } from '../../data/constants/config';
55

6-
type GetSponsorDataProps = 'prospectus' | 'sporsor-benefit' | 'sponsor-join' | 'sponsor-faq' | 'terms-of-sponsor';
6+
type SponsorDataEndPointType = 'prospectus' | 'sporsor-benefit' | 'sponsor-join' | 'sponsor-faq' | 'terms-of-sponsor';
77

8-
export const getSponsorData = async (endPoint: GetSponsorDataProps): Promise<IContents> => {
9-
try {
10-
const response = await axios.get(
11-
`${API_SERVER}/content/${endPoint}`
12-
)
13-
const data: IApiContents = response.data
8+
export const getSponsorData = async (endPoint: SponsorDataEndPointType): Promise<IContents> => {
9+
const response = await axios.get(
10+
`${API_SERVER}/content/${endPoint}`
11+
);
12+
const data: IApiContents = response.data;
1413

15-
return {
16-
content: {
17-
ko: data.content,
18-
en: data.eng_content
19-
}
14+
return {
15+
content: {
16+
ko: data.content,
17+
en: data.eng_content
2018
}
21-
} catch (error) {
22-
window?.alert('일시적인 오류가 발생하였습니다. 잠시 후 다시 시도해 주세요.')
2319
}
24-
2520
}
2621

0 commit comments

Comments
 (0)