I'm having troubles getting chrome storage API to work in MV3. I've tried this so far and even in the service worker console it returns an undefined result
chrome.storage.local.set({ 'test': 'test' }, function() {
chrome.storage.local.get('test', function(result) {
console.log('Value currently is ' result);
});
});
Here is my manifest I'm not sure if that's an issue
{
"manifest_version": 3,
"name": "NAME",
"description": "Description",
"version": "0.0.3",
"background": {
"service_worker": "background.js"
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"action": {
"default_icon": {
"16": "favicon.ico"
},
"default_title": "Outboundly",
"default_popup": "index.html"
},
"permissions": [
"storage",
"scripting",
"activeTab",
"tabs",
"unlimitedStorage"
],
"host_permissions": ["<all_urls>"]
}
I've also tried it in the content script and within the popup context as well.
CodePudding user response:
Should you call in ['test']
?
chrome.storage.local.set({key: value}, function() {
console.log('Value is set to ' value);
});
chrome.storage.local.get(['key'], function(result) {
console.log('Value currently is ' result.key);
});
CodePudding user response:
I'm not sure why but I changed the position of the permissions around in the manifest, and that seemed to have fixed things. Possibly a bug.