mirror of
https://github.com/khairul169/db-backup-tool.git
synced 2025-04-28 16:49:34 +07:00
16 lines
465 B
TypeScript
16 lines
465 B
TypeScript
import { ClientResponse, hc } from "hono/client";
|
|
import type { AppRouter } from "../../../backend/src/routers";
|
|
|
|
const api = hc<AppRouter>("http://localhost:3000/");
|
|
|
|
export const parseJson = async <T>(res: ClientResponse<T>) => {
|
|
const json = await res.json();
|
|
if (!res.ok) {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
throw new Error((json as any)?.message || "An error occured.");
|
|
}
|
|
return json as T;
|
|
};
|
|
|
|
export default api;
|