I’m trying to get some values from local storage but I can’t figure out how to return a value from a promise. I would like to have the storage getter inside a function so I can call it when needed, everything I try results in a pending state from the promise. I tried using resolve but I’m not sure if it works like this.
function getter() {
var get = browser.storage.local.get().then(storage => {
resolve(storage);
}, onError);
return get;
}
console.log(getter());
Is there any reason this does not work? The promise has been resolved successfully and is pushed to the responseHeaders array, but it does not get applied to the website for some reason.
I see you added that comment, I knew that it is going to be bad for performance since it is calling on every headerReceived. I am calling the local storage to get an array of url’s to check against. Is there any way to make it less resource intensive?
This is currently what I am doing, and I know its really bad.
await browser.storage.local.get(null).then(checkSettings);
const get = await browser.storage.local.get(null);