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 }>(