This repository was archived by the owner on Jul 19, 2019. It is now read-only.
server.js updates comments variable after get request to "comments.json" #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the fetching data from the server section of the tutorial documentation, a method to poll the server is added so that the app polls the server every 2 seconds for changes to the server's _comments.json data (which will then reflected through dynamic updates to the DOM). Section of tutorial below:
Here, in the tutorial, after adding the server polling it encourages you to change the _comments.json file so that you can see the app dynamically change when new information is obtained from the server.
The server file is setup to just fetch json data from a static file (_comments.json) by reading the file and then storing the contents of the file in a variable 'comments'. Then on a get requests to comments.json, the server sends the stringified comments data as a response. The problem is that the _comments.json file is currently only read one time by the server and never reread, so changes to the _comments.json file never change the comments variable.
This push request updates the server.js file so that the server will re-read the _comments.json file and update the comments variable after every get request to comments.json.