kumard3
kumard315mo ago

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

i am using trpc with next js ,
4 Replies
Nick
Nick15mo ago
Can you share some more detail on what you’re trying to achieve?
kumard3
kumard315mo ago
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));
}
Nick
Nick15mo ago
Is this in the procedure on your backend? That does sound like the best way
kumard3
kumard315mo ago
Yes it is inside a mutation , and after I get a success url from stripe