tRPCttRPC
Powered by
hashwarpH
tRPC•2y ago•
1 reply
hashwarp

createCaller is returning [Function: noop]

env: node 20 pnpm

I'm trying to call procedures locally, and when I console log the router, I see the trpc object (
{mutations: ..., etc.}
{mutations: ..., etc.}
)

But when I create the caller, it returns noop, and anything I call on that is noop. Ideas?

client.emit = createRouter(service);

const createCaller = createCallerFactory(client.emit);
const caller = createCaller({ client );
const result = await caller.connected(params);
client.emit = createRouter(service);

const createCaller = createCallerFactory(client.emit);
const caller = createCaller({ client );
const result = await caller.connected(params);


router:

export const createRouter = (service: Schema.Service) => {
  return router({
    connected: procedure
      .use(hasRole('realm', t))
      .use(customErrorFormatter(t))
      .input(schema.connected)
      .mutation(({ input, ctx }) => service.connected(input as Schema.ConnectedInput, ctx))
  })
}
export const createRouter = (service: Schema.Service) => {
  return router({
    connected: procedure
      .use(hasRole('realm', t))
      .use(customErrorFormatter(t))
      .input(schema.connected)
      .mutation(({ input, ctx }) => service.connected(input as Schema.ConnectedInput, ctx))
  })
}
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Deprecated createCaller alternative?
HichHHich / ❓-help
13mo ago
CreateCaller with React-query
lunacraftsLlunacrafts / ❓-help
2y ago
Cannot access 'createCaller' before initialization
Answer OverflowAAnswer Overflow / ❓-help
2y ago
Is it ok to use a createCaller() router within ServerSideProps?
denik1981Ddenik1981 / ❓-help
4y ago