import type { Router } from '../../../server/src/routers' export const trpcClient = createTRPCProxyClient<Router>({ links: [ httpBatchLink({ url: `${env.SERVER_URI}/trpc` }) ] })
const user = await trpcClient.user.create.mutate({ email: string; password: string })
any
const user = await trpcClient.user.create.mutate({ email: string; password: string }).catch((error) => { // error is any }
errorFormatter
const t = initTRPC.context<Context>().create({ isDev: env.NODE_ENV !== 'production', errorFormatter: ({ shape, error }) => { return { ...shape, data: { ...shape.data, customError: error.cause instanceof CustomError ? error.cause.customCode : null } } } })
const user = await trpcClient.user.create.mutate({ email: string; password: string }).catch((error) => { const parsedError = errorSchema.safeParse(error) if (parsedError.isSuccess) { console.error(parsedError.data.data.customError) } else { console.error(error) } }