#Next.js and webhooks vs polling

2 messages · Page 1 of 1 (latest)

iron pewter
#

I am implementing a video upload functionality. I have an entity "A" for which I want to upload the video. I want to return a status "ok" to indicate that the video upload has been initiated, but I also want to refetch this entity once the upload is successfully completed. I am using React Query, but calling refetch or invalidating the query on success won't work, as the upload takes a few seconds.

What is the best approach in Next.js? I have flexibility in how to implement this, but I am aiming for an efficient solution, i.e., minimizing API calls and avoiding unnecessary re-renders.

Is it better to create a webhook or just a separate endpoint to check the status of the upload and refetch the entity upon successful upload?

warm knollBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)