I'm trying to use chrome storage in an extension, via a content_script, but I keep failing on
Uncaught TypeError: Cannot read property 'sync' of undefined  This is my code:
testChromeStorage();  function testChromeStorage() {       console.log("Saving");     chrome.storage.sync.set({'value': theValue}, function() {         message('Settings saved');     });     chrome.storage.sync.get("value", function (retVal) {             console.log("Got it? " + retVal.value);     }); } You have to add the "storage" permission in your manifest.json file, i.e.:
...   "permissions": [     "storage"   ], ... For more information, see: https://developer.chrome.com/extensions/storage
RELOAD THE EXTENSION
I had the "permissions" key added in my manifest file but still I struggled to get this fixed.
After adding the permission:-
"permissions": [     "storage"  ] Goto your extension using: chrome://extensions/ & click the Reload button:-

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With