mirror of
https://github.com/usatiuk/y.git
synced 2025-10-29 02:37:49 +01:00
show error popup
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// import { apiRoot } from "~src/env";
|
// import { apiRoot } from "~src/env";
|
||||||
|
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
|
import { isError } from "./dto";
|
||||||
|
|
||||||
const apiRoot: string = "http://localhost:8080";
|
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(() => {
|
const json = await response.json().catch(() => {
|
||||||
return {};
|
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 }>(
|
export async function fetchJSONAuth<T, P extends { parse: (arg: string) => T }>(
|
||||||
|
|||||||
Reference in New Issue
Block a user