I wrote a Chrome extension. I cannot use localStorage.setItem and localStorage.getItem to save and retrieve, because the background and browser actions are executed in a different environment [ as shown 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 caused the following error:
Uncaught TypeError: Cannot read the 'local' property from undefined
What am I doing wrong?
source share