https://api.github.com/jellydn/untypeable-wretch-demo/blob/f22201850aa9e3b4fba6a0eeadd1bcc7b10e60f7/src/api-client.ts#L51
});
const mutationRouter = u.router({
"/posts": u
.input(
z.object({
title: z.string(),
body: z.string(),
userId: z.number(),
})
)
.output(
z.object({
id: z.number(),
title: z.string(),
body: z.string(),
userId: z.number(),
})
),
});
const BASE_URL = "https://jsonplaceholder.typicode.com";
const externalApi = wretch(BASE_URL, { mode: "cors" }).errorType("json");
// TODO: support mutations (PUT, PATCH, DELETE), refer to https://github.com/total-typescript/untypeable#pusharg
export const fetcher = createTypeLevelClient<typeof fetcherRouter>(
async (path, input) => {
const res = externalApi.get(`${path}?${new URLSearchParams(input)}`);