// 학습자: 함수 이름을 동작을 드러내는 이름으로 바꾸세요. // (test 파일은 새 이름으로 import 합니다.) export const __log: { url: string; method: string }[] = []; export async function fetchJSON<T>(url: string): Promise<T> { __log.push({ url, method: 'GET' }); // 표준 fetch와 달리: 자동 JSON 파싱 + non-2xx 시 throw + 결과 캐싱 return { ok: true, url } as unknown as T; } export async function getWithAuth<T>(url: string): Promise<T> { __log.push({ url, method: 'GET' }); // 자동: Authorization 헤더, retry, cache-bust 타임스탬프 return { ok: true, auth: true } as unknown as T; } export async function postWithCSRF<T>(url: string, data: unknown): Promise<T> { __log.push({ url, method: 'POST' }); // 자동: CSRF 헤더, 응답에서 토큰 refresh return { ok: true, posted: data } as unknown as T; } export async function softDelete(url: string): Promise<void> { __log.push({ url, method: 'POST' }); // 실제로는 DELETE 가 아니라 { _deleted: true } 로 soft delete }
Tests