Warm tip: This article is reproduced from stackoverflow.com, please click
api javascript

How to store retrieved data from API locally and update those data at equal interval using Javascrip

发布于 2020-03-27 10:15:12

I am building a webpage using web-services in Java Script. Currently, I have implemented the API and it displays the data on webpage. But, many time due to server failure data is not received and web page becomes empty.

So, I want to fetch data from API and store it locally and update those data at equal time interval. So, my application can always use locally stored data and web page never becomes empty.

How to do that, please share your views.?

Questioner
Praful Patel
Viewed
182
cnps 2019-07-03 21:29

As far as I can tell, you want to store data locally every time you fetch from API, so when you open the page next time, it will display last fetched data.

In that case, localStorage can be used. However, local storage should not be used for sensitive data and advanced objects. Also, it's stored as string data (JSON), so that also has some limitations.