Skip to content

Commit 87fe134

Browse files
feat: 아티클 상세 조회 api axios, query 함수 작성
1 parent 093a1c5 commit 87fe134

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

apps/client/src/shared/apis/axios.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export const postSignUp = async (responsedata: postSignUpRequest) => {
4040
return data;
4141
};
4242

43+
export const getArticleDetail = async (articleId: number) => {
44+
const { data } = await apiRequest.get(`/api/v1/articles/${articleId}`);
45+
return data;
46+
};
47+
4348
export const putEditArticle = async (
4449
articleId: number,
4550
editArticleData: EditArticleRequest

apps/client/src/shared/apis/queries.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import {
66
postSignUpRequest,
77
putEditArticle,
88
putCategory,
9+
getArticleDetail,
10+
getAcorns,
911
} from '@shared/apis/axios';
1012
import { AxiosError } from 'axios';
1113
import {
1214
DashboardCategoriesResponse,
1315
AcornsResponse,
1416
EditArticleRequest,
17+
ArticleDetailResponse,
1518
} from '@shared/types/api';
16-
import { getAcorns } from './axios';
1719

1820
export const useGetDashboardCategories = (): UseQueryResult<
1921
DashboardCategoriesResponse,
@@ -62,6 +64,16 @@ export const usePostSignUp = () => {
6264
});
6365
};
6466

67+
export const useGetArticleDetail = (
68+
articleId: number
69+
): UseQueryResult<ArticleDetailResponse, AxiosError> => {
70+
return useQuery({
71+
queryKey: ['articleDetail', articleId],
72+
queryFn: () => getArticleDetail(articleId),
73+
enabled: !!articleId,
74+
});
75+
};
76+
6577
export const usePutEditArticle = () => {
6678
return useMutation({
6779
mutationFn: ({

apps/client/src/shared/types/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,18 @@ export interface EditArticleRequest {
1919
now: string;
2020
remindTime: string;
2121
}
22+
23+
interface CategoryResponse {
24+
categoryId: number;
25+
categoryName: string;
26+
categoryColor: string;
27+
}
28+
29+
export interface ArticleDetailResponse {
30+
id: number;
31+
url: string;
32+
memo: string;
33+
remindAt: string;
34+
createdAt: string;
35+
categoryResponse: CategoryResponse;
36+
}

0 commit comments

Comments
 (0)