mirror of
https://github.com/usatiuk/y.git
synced 2025-10-28 10:37:47 +01:00
show error popup
This commit is contained in:
@@ -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, P extends { parse: (arg: string) => 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, P extends { parse: (arg: string) => T }>(
|
||||
|
||||
Reference in New Issue
Block a user