Tarky
Tarky10mo ago

Error while creating a mutation in NextJS

I am having the following error:
"message": "No \"query\"-procedure on path \"checkout.stripe\"",
"code": -32004,
"message": "No \"query\"-procedure on path \"checkout.stripe\"",
"code": -32004,
Here is my code:
import { createTRPCRouter, publicProcedure } from "@/server/api/trpc";

export const checkoutRouter = createTRPCRouter({
stripe: publicProcedure.mutation(() => {
return "Hello";
}),
});
import { createTRPCRouter, publicProcedure } from "@/server/api/trpc";

export const checkoutRouter = createTRPCRouter({
stripe: publicProcedure.mutation(() => {
return "Hello";
}),
});
If I go to http://localhost:3000/api/trpc/checkout.stripe it throws that error, any ideas?
5 Replies
Nick
Nick10mo ago
Where are you attaching checkoutRouter?
Tarky
Tarky10mo ago
In the root file, where all my routes go I am using the T3 stack here is the root.ts file
import { exampleRouter } from "@/server/api/routers/example";
import { imageRouter } from "@/server/api/routers/image";
import { checkoutRouter } from "@/server/api/routers/checkout";
import { createTRPCRouter } from "@/server/api/trpc";

/**
* This is the primary router for your server.
*
* All routers added in /api/routers should be manually added here.
*/
export const appRouter = createTRPCRouter({
example: exampleRouter,
image: imageRouter,
checkout: checkoutRouter,
});

// export type definition of API
export type AppRouter = typeof appRouter;
import { exampleRouter } from "@/server/api/routers/example";
import { imageRouter } from "@/server/api/routers/image";
import { checkoutRouter } from "@/server/api/routers/checkout";
import { createTRPCRouter } from "@/server/api/trpc";

/**
* This is the primary router for your server.
*
* All routers added in /api/routers should be manually added here.
*/
export const appRouter = createTRPCRouter({
example: exampleRouter,
image: imageRouter,
checkout: checkoutRouter,
});

// export type definition of API
export type AppRouter = typeof appRouter;
Nick
Nick10mo ago
Oh I see it, you're calling a query for a mutation procedure
Tarky
Tarky10mo ago
What do you mean?
Nick
Nick10mo ago
publicProcedure.mutation No "query"-procedure on path "checkout.stripe" It has to be one or the other