An alternative option is to utilize the localStorage
, which solely accepts string values, necessitating you to serialize your data prior to storage. Perhaps it might be worth exploring converting your application into a PWA (Progressive Web App)? This could enable extensive caching capabilities to enhance the performance of your app, such as faster load times achieved by pre-caching files within the browser.
If you remain insistent on employing localStorage
, the following approach can be taken:
var data = [{"test": {}}]; // Sample json data
localStorage.setItem(<KEY NAME>, JSON.stringify(data));
// To retrieve the stored data
var saved = localStorage.getItem(<KEY NAME>)
console.log(JSON.parse(saved));