From ffdddaf647af7d0bb7b0cb7ba72e5cd5da7babd3 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 30 Dec 2023 12:44:47 +0100 Subject: [PATCH] show error popup --- client/src/api/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/api/utils.ts b/client/src/api/utils.ts index ee7cb23..6fa2adb 100644 --- a/client/src/api/utils.ts +++ b/client/src/api/utils.ts @@ -1,6 +1,7 @@ // import { apiRoot } from "~src/env"; import { jwtDecode } from "jwt-decode"; +import { isError } from "./dto"; const apiRoot: string = "http://localhost:8080"; @@ -59,7 +60,11 @@ export async function fetchJSON T }>( const json = await response.json().catch(() => { return {}; }); - return parser.parse(json); + const parsed = parser.parse(json); + if (isError(parsed)) { + alert(parsed.errors.join(", ")); + } + return parsed; } export async function fetchJSONAuth T }>(