santi
santi2y ago

How can I access ctx from inside of a procedure?

const appRouter = t.router({
helloTab: t.procedure.input(z.object({ url: z.string().url() })).mutation(async ({ input, ctx }) => {
//@ts-ignore
const tab = ctx.sender.tab
console.log(tab)
}),
});
const appRouter = t.router({
helloTab: t.procedure.input(z.object({ url: z.string().url() })).mutation(async ({ input, ctx }) => {
//@ts-ignore
const tab = ctx.sender.tab
console.log(tab)
}),
});
is something like this possible? Not working for me
1 Reply
Nick
Nick2y ago
That’s how it works yes, did you forget to set the type in initTRPC?