Browse Source

add throw in get

visuddhinanda 2 năm trước cách đây
mục cha
commit
72325b4642
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  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;
 };