kumard3
kumard32y 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
Nick2y ago
Can you share some more detail on what you’re trying to achieve?
kumard3
kumard3OP2y 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
Nick2y ago
Is this in the procedure on your backend? That does sound like the best way
kumard3
kumard3OP2y ago
Yes it is inside a mutation , and after I get a success url from stripe