I have written a Chrome extension. I cannot use
localStorage.setItem
and localStorage.getItem
for storing and retrieving because background and browser action runs in different environment [as seen here].
So I decided to use the Chrome storage API:
var storage = chrome.storage.local;
var myTestVar = 'somevar';
var obj = {};
obj[myTestVar] = $("#somevar").val();
storage.set(obj);
which produced the following error:
Uncaught TypeError: Cannot read property 'local' of undefined
What am I doing wrong?
You'll get this error if you try running your app as a simple HTML page opening the HTML file in Chrome.
Add the app in Chrome properly (as an Extension) then run it.
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