You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Press component, data is fetched from the New York Times API and stored in local storage so that the data is retrieved and used if it already exists next time the client navigates to this page. The data already in local storage however is used indefinitely yet new articles are being added to the API periodically.
It is therefore important to add a time frame within which data in local storage is usable. This can be 24 hours, 48 hours e.t.c
This can be achieved by adding the current date from Date.now() and deferring data retrieval from the API if the difference between Date.now() and date in local storage is less than 24 * 60 * 60 * 1000. Of course the 24 is if it is decided that the "expiry" time frame is 24 hours.
The text was updated successfully, but these errors were encountered:
nibble0101
changed the title
Use of data stored in local storage doesn't have a trime frame.
Use of data stored in local storage doesn't have a time frame.
Oct 28, 2020
In the
Press
component, data is fetched from the New York Times API and stored inlocal storage
so that the data is retrieved and used if it already exists next time the client navigates to this page. The data already inlocal storage
however is used indefinitely yet new articles are being added to the API periodically.It is therefore important to add a time frame within which data in local storage is usable. This can be 24 hours, 48 hours e.t.c
This can be achieved by adding the current date from
Date.now()
and deferring data retrieval from the API if the difference betweenDate.now()
and date in local storage is less than24 * 60 * 60 * 1000
. Of course the24
is if it is decided that the "expiry" time frame is 24 hours.The text was updated successfully, but these errors were encountered: