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");
})();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.