-
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.
* FE-52 feat: api schema 작성 * FE-52 ✨feat: getEpigrams api 작성 * FE-522 ✨fix: default export로 변경 * FE-52 ✨test: 테스트 코드 작성 * FE-52 ✨feat: BaseUrl, TeamID 상수 추가 및 axios baseTRL 수정 * FE-52 ✨fix: schema 및 apis 파일 수정 * FE-52 ✨test: 테스트 코드 삭제 * FE-52 ✨fix: .env파일 생성 및 BaseURL 수정 * FE-52 ✨fix: limit 타입 수정(optional 삭제) * FE-52 ✨text: 테 테스트코드 삭제 * FE-52 ✨fix: api GET요청 주소 수정('epigrams' -> '/epigrams')
- Loading branch information
1 parent
cdede81
commit f78ea94
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { GetEpigramsParamsType, GetEpigramsResponseType, GetEpigramsResponse } from '@/schema/epigrams'; | ||
import httpClient from '.'; | ||
|
||
const getEpigrams = async (params: GetEpigramsParamsType): Promise<GetEpigramsResponseType> => { | ||
const response = await httpClient.get(`/epigrams`, { params }); | ||
|
||
// 데이터 일치하는지 확인 | ||
const parsedResponse = GetEpigramsResponse.parse(response.data); | ||
return parsedResponse; | ||
}; | ||
|
||
export default getEpigrams; |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as z from 'zod'; | ||
|
||
export const GetEpigramsParams = z.object({ | ||
limit: z.number(), | ||
cursor: z.number().optional(), | ||
keyword: z.string().optional(), | ||
writerId: z.number().optional(), | ||
}); | ||
|
||
export const GetEpigramsResponse = z.object({ | ||
totalCount: z.number(), | ||
nextCursor: z.number(), | ||
list: z.array( | ||
z.object({ | ||
likeCount: z.number(), | ||
tags: z.array( | ||
z.object({ | ||
name: z.string(), | ||
id: z.number(), | ||
}), | ||
), | ||
writerId: z.number(), | ||
referenceUrl: z.string(), | ||
referenceTitle: z.string(), | ||
author: z.string(), | ||
content: z.string(), | ||
id: z.number(), | ||
}), | ||
), | ||
}); | ||
|
||
export type GetEpigramsParamsType = z.infer<typeof GetEpigramsParams>; | ||
export type GetEpigramsResponseType = z.infer<typeof GetEpigramsResponse>; |