I need to access the localStorage of a chrome extension in background.js
to get values which have been set by the extension popup itself. The key-value pair is existing, I checked that by inspecting the extension popup.
However, reading from the localStorage by using the code below leads to an undefined
result.
background.js:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
chrome.storage.local.get(['allowedSites'], function(result) {
console.log('allowedSites: ', result.allowedSites);
});
}
);
The storage
permission is set in v3 manifest. Any ideas what's wrong with this code?