I can't understand why this is throwing that error when I am working inside async await functions... Not sure if makes a difference but I am executing this code inside the content script of a chrome extension
Thanks in advance!
const getFromStorage = async function(key) {
return new Promise((resolve, reject) => {
chrome.storage.sync.get(key, resolve);
})
.then(result => {
if (key == null) return result;
else return result[key];
});
}
let updateArray = await getFromStorage("toSaveArray");
Top level await is not yet supported
You probably have to use an an Anonymous Function, for example:
(async () => {
let updateArray = await getFromStorage("toSaveArray");
})();