import { createFetcher, Output } from "t_rest/client"; import { ApiHandler } from "../api/serveApi.ts"; export const fetchApi = createFetcher({ baseUrl: `${location.origin}/api/`, }); export function handleResponse( response: T, ): (T & { status: 200 })["body"]["data"] { if (response.status !== 200) { throw new Error(String(response.body.data)); } return response.body.data; }