Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
Getting this error "await is only valid in async functions and the top level bodies of modules" in chrome extension with async await

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");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Top level await is not yet supported

You probably have to use an an Anonymous Function, for example:

(async () => {
  let updateArray = await getFromStorage("toSaveArray");
})();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!