feat(dados-client): adotar react query em leituras do app

This commit is contained in:
Felipe Coutinho
2026-04-03 18:10:34 +00:00
parent e4c6a91350
commit acaf9d5c27
14 changed files with 409 additions and 150 deletions

View File

@@ -0,0 +1,26 @@
export async function fetchJson<T>(
input: RequestInfo | URL,
init?: RequestInit,
): Promise<T> {
const response = await fetch(input, {
cache: "no-store",
...init,
});
if (!response.ok) {
let message = `Erro na requisição (${response.status})`;
try {
const payload = (await response.json()) as { error?: string };
if (payload.error) {
message = payload.error;
}
} catch {
// noop
}
throw new Error(message);
}
return response.json() as Promise<T>;
}