If I had a URL like https://jsonplaceholder.typicode.com/users which would return say 10,000 JSON objects instead of 10, or say even simpler, 100 full-formatted JSON strings which takes 1 minute for fetching each of the 100 JSON string from the database, how do I use fetch on client-side javascript to keep 'wait'ing for the next response from the server until 100 is reached (100 for simplicity sake, will stop based on a message from the last JSON sting) ?
Most of the long polling examples makes use of polling at regular intervals.
As you can see, subscribe function makes a fetch, then waits for the response, handles it and calls itself again.
if (response.status == 200)
// Call subscribe() again to get the next message
await subscribe();
This is not what I want.
EDIT : I understand this can be easily achieved using websockets, but this requires me creating another server for the ws: protocol from my regular Django server at 8000 ? I was hoping to create a django end point REST URL to return data at regular intervals that would take some good amount of time.