I have been browsing around the Web for a similar question but no luck, I will explain what I want to happen and if someone can point me in the right way:
What I have currently:
- A basic next.js app with 2 pages, and 1 api page listening for get/post requests
What's happening:
- I have an external program making post requests to my next.js api passing through a json object representing a "user" and storing it in an array (for now)
- My front end is looping and refreshing that data via a get request to the same endpoint
The Problem:
- Well given my loop is happening every 10 seconds a requests that came through just after the list refreshed won't show until the next refresh (10 seconds later). I was wondering if next.js has any built in functionality for when my api is posted to, force the front end to request the newest data? I was thinking of separating this out into a front end and back end app and use websockets but while I have the next.js app running if they're any alternatives?
Happy to hear any ideas?