Need help

import {initTRPC} from '@trpc/server';
import * as trpcNext from '@trpc/server/adapters/next';
import {z} from 'zod';
const t=initTRPC.create();
const appRouter=t.router({greetings:t.procedure.input(z.object({name:z.string()}))})
.query(({input})=>{return {text:`hello ${input?.name ??'world'}`}});
export type AppRouter=typeof appRouter;
export default trpcNext.createNextApiHandler({router:appRouter,createContext:()=>({})})
import {initTRPC} from '@trpc/server';
import * as trpcNext from '@trpc/server/adapters/next';
import {z} from 'zod';
const t=initTRPC.create();
const appRouter=t.router({greetings:t.procedure.input(z.object({name:z.string()}))})
.query(({input})=>{return {text:`hello ${input?.name ??'world'}`}});
export type AppRouter=typeof appRouter;
export default trpcNext.createNextApiHandler({router:appRouter,createContext:()=>({})})
why does t.query is not a function?
4 Replies
i_lost_to_loba_kreygasm
the error I am getting
Michael Schaufelberger
You are calling .query on the t.router(...) instead of the procedure:
Michael Schaufelberger
you need to call it in the t.procedure chain. I.e. after .input(...)