전체적인 리팩토링
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
||||
DashboardActivityResponse,
|
||||
DashboardBalanceResponse,
|
||||
DashboardIndicesResponse,
|
||||
DashboardMarketHubResponse,
|
||||
} from "@/features/dashboard/types/dashboard.types";
|
||||
|
||||
/**
|
||||
@@ -92,3 +93,31 @@ export async function fetchDashboardActivity(
|
||||
|
||||
return payload as DashboardActivityResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 급등/인기/뉴스 시장 허브 데이터를 조회합니다.
|
||||
* @param credentials KIS 인증 정보
|
||||
* @returns 시장 허브 응답
|
||||
* @see app/api/kis/domestic/market-hub/route.ts 서버 라우트
|
||||
*/
|
||||
export async function fetchDashboardMarketHub(
|
||||
credentials: KisRuntimeCredentials,
|
||||
): Promise<DashboardMarketHubResponse> {
|
||||
const response = await fetch("/api/kis/domestic/market-hub", {
|
||||
method: "GET",
|
||||
headers: buildKisRequestHeaders(credentials),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const payload = (await response.json()) as
|
||||
| DashboardMarketHubResponse
|
||||
| KisApiErrorPayload;
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
resolveKisApiErrorMessage(payload, "시장 허브 조회 중 오류가 발생했습니다."),
|
||||
);
|
||||
}
|
||||
|
||||
return payload as DashboardMarketHubResponse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user