-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot call browser.storage.local.get with callback; Error: Expected at most 1 argument for get(), got 2 #102
Comments
You shouldn't use the file from src/, but the output in dist/. |
Thanks @Rob--W I used the pre-built version and now I have this error: https://i.imgur.com/OV8Da6X.png What can I do to resolve it and having the addon working on Chromium ? Regards |
That's because you're using: function getSettings() {
return new Promise(function (resolve, reject) {
browser.storage.local.get("Settings", function (value) {
Settings = value.Settings;
resolve(Settings);
});
})
} That should work (it is a bug in the polyfill if it does not), but a work-around is to use: function getSettings() {
return new Promise(function (resolve, reject) {
browser.storage.local.get("Settings").then(function (value) {
Settings = value.Settings;
resolve(Settings);
});
})
} But with this polyfill, you don't need to wrap in a function getSettings() {
return browser.storage.local.get("Settings").then(function (value) {
Settings = value.Settings;
return Settings;
});
} or even with async/await syntax: async function getSettings() {
let value = await browser.storage.local.get("Settings");
Settings = value.settings;
return Settings;
} |
@Rob--W Another small error here after I 've applied the workaround: https://i.imgur.com/6jpaxSJ.png Thanks for your help and time |
Hi,
I've found this polyfill and tried to convert a Firefox addon to AMO but it don't work, it throw error in the console window: each time I load the extension in Chromium: https://i.imgur.com/l9JZ5dB.png
I've load the polyfill via the manifest.json like in the exemple on the readme.
Here's a link to the source of the addon in case you need it: https://dl.dropboxusercontent.com/s/68ph7gwzoltrktv/TranslateExtension.zip
Regards
The text was updated successfully, but these errors were encountered: