From f6d2e2335d8267a9dd4fec4b31c7d06c8cacdc1a Mon Sep 17 00:00:00 2001
From: p-sw <shinwoo.park@psw.kr>
Date: Sat, 15 Jun 2024 01:59:10 +0900
Subject: [PATCH] refactor(cli): safeFetcher return response instead of json

---
 packages/cli/src/helpers/registry.ts    | 2 +-
 packages/cli/src/helpers/safeFetcher.ts | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/packages/cli/src/helpers/registry.ts b/packages/cli/src/helpers/registry.ts
index efd370c..ef46c29 100644
--- a/packages/cli/src/helpers/registry.ts
+++ b/packages/cli/src/helpers/registry.ts
@@ -7,7 +7,7 @@ export async function getRegistry(
   const registryResponse = await safeFetch(REGISTRY_URL(branch ?? 'main'))
 
   if (registryResponse.ok) {
-    const registryJson = registryResponse.json as Registry
+    const registryJson = (await registryResponse.response.json()) as Registry
     registryJson.base = registryJson.base.replace('{branch}', branch ?? 'main')
 
     return {
diff --git a/packages/cli/src/helpers/safeFetcher.ts b/packages/cli/src/helpers/safeFetcher.ts
index 7f63d5b..c9ed4bd 100644
--- a/packages/cli/src/helpers/safeFetcher.ts
+++ b/packages/cli/src/helpers/safeFetcher.ts
@@ -2,12 +2,12 @@ import fetch, {Response} from 'node-fetch'
 
 export async function safeFetch(
   url: string,
-): Promise<{ok: true; json: unknown} | {ok: false; message: string; response: Response}> {
+): Promise<{ok: true; response: Response} | {ok: false; message: string; response: Response}> {
   const response = await fetch(url)
   if (response.ok) {
     return {
       ok: true,
-      json: await response.json(),
+      response,
     }
   }