I'm trying to access the local storage data in Edge set by my options page, using my popup script. Is there a current, working example of this available?

I was using localStorage, but it would only update the popup if I reloaded the extension after saving changes in my options page. I want to make it easier on the user by allowing the popup to access it immediately after saving, without reloading. I found the browser.storage.local.get(), but documentation conflicts everywhere I look, and I can't find viable working examples.

I have used, per Edge documentation:


But it throws an error requiring a callback function. So then I used:

let sample = browser.storage.local.get("example");
sample.then(ifGood, ifBad);

I get an error regarding property "then".

Then I simply tried adding a callback to the action itself:

sample = browser.storage.local.get("example", callbackFunction);

function callbackFunction(data){

The end alert should display a string, but it just displays an empty Object. How do I access the data returned in the callback? I tried callbackFunction(this) as an argument in the get, but it throws an error about the syntax of the get.

1 Answers

Michael Rudd On

I found a work-around using browser.runtime.reload() in the Options page when saving the changes. It still reloads the extension, but it does it without requiring the user to do it manually.