React-toastify display toast from Next.js api route

Hey guys, I currently has a system flow that works as follows using t3 stack: 1. User submits form on frontend 2. Some processing is offloaded to AWS Lambda by trpc procedure and procedure quits 3. Once Lambda is finished, it calls a next.js backend api route I'd like to display some feedback to the user once the next.js api route is called by Lambda, preferrably in the form of a react-toastify toast. Is it possible to invoke a frontend toast from the backend? If not, how would I go about doing something similar?
5 Replies
MALEV0L3NT
MALEV0L3NTOP14mo ago
Is there maybe a way I can set some state in the api route and have the frontend listening for when that state changes? I'm not sure if anything like this exists but it's really the only thing I can think of
H
H14mo ago
I believe u can do something like res.send("the function is starting") on the first line of that next api route it will send a res without ending the exécution of the func u can then show that response on a toast in frontend Tho res.send is express syntax u have to find equivalent of that in next
MALEV0L3NT
MALEV0L3NTOP14mo ago
I don't think this will work as AWS Lambda is calling the api route, not the frontend. The api route and frontend are completely disconnected here I eventually realised that I was asking the completely wrong question here....
Vengeance
Vengeance14mo ago
you would either need to toast when the trpc procedure ends (have it wait for lambda to finish before quitting) or have lambda send a webhook to the user
MALEV0L3NT
MALEV0L3NTOP14mo ago
How would that webhook idea work?
Want results from more Discord servers?
Add your server