Tarky
Tarky
TtRPC
Created by Tarky on 2/25/2025 in #❓-help
Catch the error on trycatch and show the message
Hello, I am throwing a TRPCError inside my procedure
throw new TRPCError({
code: "BAD_REQUEST",
message: "Not enough credits",
});
throw new TRPCError({
code: "BAD_REQUEST",
message: "Not enough credits",
});
How can I get this message in my react onSubmit handler?
async function onSubmit(values: z.infer<typeof formSchema>) {
try {
await createImage({
prompt: values.prompt,
type: values.type,
});

router.refresh();
} catch (cause) {
console.log(cause);
toast({
title: "Error",
description:
"An error occurred while creating your image. Please try again.",
});
}
}
async function onSubmit(values: z.infer<typeof formSchema>) {
try {
await createImage({
prompt: values.prompt,
type: values.type,
});

router.refresh();
} catch (cause) {
console.log(cause);
toast({
title: "Error",
description:
"An error occurred while creating your image. Please try again.",
});
}
}
`
3 replies
TtRPC
Created by Tarky on 10/9/2023 in #❓-help
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?
9 replies