T
tRPC

how can i send a request to specific route in trpc server, after mutation ?

how can i send a request to specific route in trpc server, after mutation ?

Kkumard35/10/2023
i am using trpc with next js ,
Nnlucas5/10/2023
Can you share some more detail on what you’re trying to achieve?
Kkumard35/10/2023
Actually I am using stripe on trpc server , and after I get a success_url from it I wanted to send a request to /api/contact Just for follow up we can only add one url to success_url , given by stipe so i kind of did it , but can you tell me if it is good approach or not
if (session.success_url) {
const url = session.success_url;
const newUrl = url.replace(`/test/success`, '/api/contact');
await fetch(newUrl).then((res) => {
if (res.status === 200) {
console.log("Thank you for contacting us!");
} else {
console.log("Email/Password is invalid.");
}
})
.catch((e) => console.log(e));
}
if (session.success_url) {
const url = session.success_url;
const newUrl = url.replace(`/test/success`, '/api/contact');
await fetch(newUrl).then((res) => {
if (res.status === 200) {
console.log("Thank you for contacting us!");
} else {
console.log("Email/Password is invalid.");
}
})
.catch((e) => console.log(e));
}
Nnlucas5/10/2023
Is this in the procedure on your backend? That does sound like the best way
Kkumard35/10/2023
Yes it is inside a mutation , and after I get a success url from stripe

Looking for more? Join the community!

T
tRPC

how can i send a request to specific route in trpc server, after mutation ?

Join Server
Recommended Posts
Help in deploymentHey all, I am building an app which is having a 1 . vite-react frontend 2 . trpc-standalone how to persist the query client?I want to persist the trpc query client cache, but don't want to create a new query client, I want tHow to infer type of a nested object from app router output?I have a tRPC router than returns a nested object through a db query. It looks like this: ```ts ILeWhat's the type of errorFormatter parameterI wanna know how could i get the type of the errorFormatter parameter, so i can move the errorFormattRPC works only for monoliths environment?How can I works if typesafe in real time with a remote server? 🤔How to use createCaller() with lambda for testing?Has anyone successfully mocked a trpc caller that uses the AWS Lambda integration? trying to write sis there a way to call useQuery() from a callback and get the return value within that callback?I have a generic component that is effectively an autocomplete that fills in options from a web requUsing Response with the Next App RouterThe route handlers in the App Router, only receive the Request object, requiring you to use a ResponThe only way to access useQuery options without input is passing undefined to it?Is there any other way? seems strange pass undefined to the input queryHow can I access the trpc context in zod's refine function?To do something like ```ts create: myProcedure .input(myInputSchema.refine(async ({ slug }, ctx)Set Request Headers for individual requests?Hello everyone, I have a simple question, can you somehow add headers to the individual requests insGet undefined when the refetch function has successfully workedIn my use case, I first disabled the useQuery function because I want it only fetch when I want to.