-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (#157) 댓글 관련 API fetch 함수 및 타입 분리
- Loading branch information
1 parent
02a0f03
commit e993416
Showing
2 changed files
with
48 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { CommentRequest, CommentResponse } from '@type/comment'; | ||
|
||
import { getFetch, postFetch, putFetch, deleteFetch } from '@utils/fetch'; | ||
|
||
export const getComment = async (postId: number): Promise<CommentResponse> => { | ||
return await getFetch<CommentResponse>(`/posts/${postId}/comments`); | ||
}; | ||
|
||
export const createComment = async (postId: number, newComment: CommentRequest) => { | ||
return await postFetch(`/posts/${postId}/comments`, newComment); | ||
}; | ||
|
||
export const editComment = async ( | ||
postId: number, | ||
commentId: number, | ||
updatedComment: CommentRequest | ||
) => { | ||
return await putFetch(`/posts/${postId}/comments/${commentId}`, updatedComment); | ||
}; | ||
|
||
export const deleteComment = async (postId: number, commentId: number) => { | ||
return await deleteFetch(`/posts/${postId}/comments/${commentId}`); | ||
}; |
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,25 @@ | ||
export interface Comment { | ||
id: number; | ||
member: { | ||
id: number; | ||
nickname: string; | ||
}; | ||
content: string; | ||
createdAt: string; | ||
isEdit: boolean; | ||
} | ||
|
||
export interface CommentResponse { | ||
id: number; | ||
member: { | ||
id: number; | ||
nickname: string; | ||
}; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
} | ||
|
||
export interface CommentRequest { | ||
content: string; | ||
} |