I would to save preferences for a WebExtension addon for Thunderbird.
I tried to use browser.storage.local.getItem(‘preference1’);
but I get error “browser.storage is undefined”. I added the permission “storage” in manifest.json.
How can I store users preferences for my WebExention addon ?
Finally I made it work, the correct syntax is
function failureCallback(error) {
console.error("Error " + error);
}
function success(itemValue) {
var value = itemValue.preference1;
}
let promiseValue = browser.storage.local.get([‘preference1’]);
promiseValue.then(success, failureCallback);
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/get
1 Like