I am storing an array URLarry, using chrome.storage.sync.set in background.js and accessing it from options.js. Everything is running perfectly fine. I can use the URLarray in options.js with no problem. But when I shutdown chrome and reopen it, all the data disappears. Please advice.
background.js
save["myKey"] = URLarray; chrome.storage.sync.set(save, function() { // console.log('Settings saved'); }); URLarray is populated as follows:
URLarray.push({website: websiteName, time:0, startTime:0, endTime:0}); options.js
chrome.storage.sync.get('myKey', function (obj) { // console.log('myKey', obj); x = obj.myKey; console.log(x); } manifest.json
{ "name": "Animated Page Action", "description": "This extension adds an animated browser action to the toolbar.", "version": "1.2", "background": { "scripts": ["jquery-3.1.1.min.js","background.js"] }, "page_action": { "default_title": "First icon", "default_icon": "icon_0.png" }, "options_page": "options.html", "permissions": ["tabs","storage"], "manifest_version": 2 }
URLarrayis a simple array so the problem is elsewhere. The posted code isn't enough to diagnose it. Use the devtools debugger to set breakpoints inside the background page script functions and check the actual values of your variables.