Skip to content

Commit a54f89c

Browse files
committed
fix: 제네릭 타입을 사용하여 data 속성에 접근하도록 수정
1 parent 6c7797f commit a54f89c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/services/application.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import apiConfig from "../config/apiConfig";
22
import { Application } from "../types/application";
33

4+
interface ApiResponse<T> {
5+
status: number;
6+
message: string;
7+
data: T;
8+
}
9+
410
export const fetchApplications = async (track?: string): Promise<Application[]> => {
511
try {
6-
const response = await apiConfig.get<Application[]>("/admin/apply", {
12+
const response = await apiConfig.get<ApiResponse<Application[]>>("/admin/apply", {
713
headers: {
814
Authorization: `Bearer ${localStorage.getItem("accessToken")}`,
915
Accept: "application/json",
1016
},
1117
params: track ? { track } : {},
1218
});
1319

14-
return response.data.data; // data 속성 내부 배열만 반환하는 것으로 수정했는데 'Application[]' 형식에 'data' 속성이 없다는 오류 발생.
20+
return response.data.data;
1521
} catch (error: any) {
1622
throw new Error(error.response?.data?.message || "지원서 목록 조회 실패");
1723
}
1824
};
19-

0 commit comments

Comments
 (0)