소스 검색

add throw in get

visuddhinanda 2 년 전
부모
커밋
72325b4642
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      dashboard/src/request.ts

+ 3 - 0
dashboard/src/request.ts

@@ -54,6 +54,9 @@ export const options = (method: string): RequestInit => {
 
 export const get = async <R>(path: string): Promise<R> => {
   const response = await fetch(backend(path), options("GET"));
+  if (!response.ok) {
+    throw response.status;
+  }
   const res: R = await response.json();
   return res;
 };