In order for my frontend to display a list with names and scores, it requires the following data:
[{id: 1, name: 'james', score: null}, {id: 2, name: 'john', score: null}]
The frontend will need to make repeated calls every second as the score values will be generated by the backend at a later time.
Therefore, the frontend will keep calling the endpoint every second until all the scores are returned.
Here are the steps detailing how the frontend should retrieve the data from the backend:
- Initiate the first call
[{id: 1, name: 'james', score: null}, {id: 2, name: 'john', score: null}]
- Render the names
Display loading indicator for scores
Make the second call
[{id: 1, name: 'james', score: 1.2}, {id: 2, name: 'john', score: 2.2}]
- Data retrieval complete, remove loading indicator
I am looking for a way to mock an endpoint in express that can provide this result to the frontend. My challenge lies in creating a non-persistent function in express that mimics when the score values will be returned.