We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 86cb993 commit 6113031Copy full SHA for 6113031
1 file changed
src/apis/post/index.ts
@@ -1,3 +1,5 @@
1
+import { useQuery } from '@tanstack/react-query';
2
+
3
import { newRequest } from '@apis/core';
4
5
import type { EmptySuccessResponse } from '@apis/core/dto';
@@ -36,3 +38,11 @@ export const deletePostApi = (postId: number) => newRequest.delete<EmptySuccessR
36
38
// 대표 게시글 지정
37
39
export const modifyPostRepresentativeStatusApi = (postId: number) =>
40
newRequest.patch<EmptySuccessResponse>(`/post/${postId}/is-representative`);
41
42
+export const usePostDetail = (postId: number) => {
43
+ return useQuery({
44
+ queryKey: ['postDetail', postId],
45
+ queryFn: () => getPostDetailApi(postId),
46
+ enabled: !!postId, // postId가 존재할 때만 요청 수행
47
+ });
48
+};
0 commit comments