Why isn't await working with async on firefox

netflix not working
netflix not loading on tv
netflix not working on smart tv
why isn't the whole world developed
netflix error code
netflix won't load on smart tv
there is a problem connecting to netflix
unable to connect to netflix smart tv

basically i have this function

async function get(url){
  const response = await fetch(url);
  const resData = await response.text();
  return resData;
}

then later i have this call

let data = await get(am_url);

the code works perfectly on google chrome, but on firefox, i get this error on the call line :

SyntaxError: await is only valid in async functions and async generators

what's the problem here, for the life of me, i can't seem to make this work on firefox and can't figure out why

for example if i open google.com on firefox and google chrome, then i go to the console, and pase this code, on chrome, it will run, but on firefox, it will throw the error i mentionned

async function get(url){
  const response = await fetch(url);
  const resData = await response.text();
  return resData;
}

let data = await get("http://google.com");
console.log(data)

In main either put your below code in self executing async function or use .then.

let data = await get(am_url);

should be changed to

(async()=>{ let data = await get(am_url) })()

or

get(am_url).then( data => ....)

Why Isn't Netflix Working, If Netflix isn't working, you may be experiencing a network connectivity issue, an issue with your device, or an issue with your Netflix app or account. To get back  Why Reopening Isn't Enough To Save The Economy : Planet Money A blockbuster new study digs into the economics of the pandemic.

As the error suggests, await only works inside async functions.

However there are 2 catches:

  1. the developer console supports await outside an async function just to simplify your life. Chrome did it first, then Firefox more recently. Your example now works in both browsers.
  2. In a future version of ECMAScript, you will be able to use await outside async functions, it's called "top-level await", so that code will soon work everywhere.

Why Isn't Church Biblical?, There is a Book out entitled The Last Christian Generation, written by Josh McDowell. This book is a read for anyone concerned about the fate of Christianity in  Why isn't Netflix working? If Netflix isn't working, you may be experiencing a network connectivity issue, an issue with your device, or an issue with your Netflix

In 2018 when this question was asked, most JavaScript consoles did not await at the top level.

At that time, Google Chrome Developer Tools console was the exception. They added the feature in late 2017 in Chrome 62

This is why, in the Firefox version you used when you asked this question, you have to resolve the promise, for example with then/catch.

If you update to a current Firefox, such as version 72 (early 2020), the code in your question will work. As fregante pointed out in a comment, in 2019, Firefox upgraded their console to support top level await.

Why Isn't a Pretty Girl Like You Married? and Other Useful Comments, She is called to grow in grace and faith and to be of great use to the kingdom of God. Marriage is a means, not an end. It is one of the means God uses to glorify  So why does it seem that Trump isn’t even trying to win? The three most significant threats to Trump’s reelection are the pandemic, the country’s terrible economic situation, and the

await won’t work in the top-level code please find reference here

Why Isn't the Whole World Developed?, Wh7y Isn't the Whole World Developed? RICHARD A. EASTERLIN. The worldwide spread of modem economic growth has depended chiefly on the dif- fusion of  A rerun is airing rather than a new episode. Why? Although new episodes will return next week, today’s is a rerun because of changes set in place due to the coronavirus outbreak.

Why isn't the Netherlands underwater? - Stefan Al, Every science channel: Make videos about coronavirus. Ted ed: Why isn't Netherlands under Duration: 5:24 Posted: 24 Mar 2020 But that isn’t true for every interesting set of numbers. As an example, let’s look at the set of numbers of the form a + b √-5, or a +i b √5, where a and b are both integers and i is the

The Economy Is A Mess. So Why Isn't The Stock Market , Employment rates, oil prices, consumer confidence and many other measures paint a clear recessionary picture. And yet stock indices continue  The Most Common Reason Your Disk Is Missing. You grabbed a nice big hard disk on sale, you cracked open your computer case, plugged the drive into the motherboard and power supply with the appropriate cables (no? better double check that before you keep reading), and when you booted your computer back up the new hard drive was nowhere to be found.

Why Isn't My Brain Working?: A Revolutionary Understanding of , Why Isn't My Brain Working?: A Revolutionary Understanding of Brain Decline and Effective Strategies to Recover Your Brain's Health: 8601420672192:  Why Isn't My Printer Printing? 6 printing issues you can fix. by. Tom Nelson. Writer. Tom Nelson is an engineer, programmer, network manager, and computer network and

Comments
  • Sounds like data might not be in an async function?
  • data isn't a function, it's supposed to hold the text content of the response, and i tried both executing it from the console as well as from within a script file in the html page, same problem, works on chrome but not on firefox
  • Why are you doing an await response.text() btw?
  • @AakashVerma because Response.text() returns a Promise?
  • I didn't say data is a function (obviously it's not), I said that it wasn't in an async function - can you post the full code so we have a minimal reproducible example to figure out?
  • That doesn't explain why one browser accepts it while the other doesn't
  • i tried the .then first but it didn't work that's when i started experimenting with different things and ended up with the code above, when i use the .then notation, sometimes i get the data as null, which means it didn't wait for the response
  • the async get function would internally pause execution when await is encountered. After the execution is finishes it will pass the data to main .then.. You can also add .catch after .then function to check if the promise is returned as Rejected
  • Firefox also added support for it in the console last year bugzilla.mozilla.org/show_bug.cgi?id=1414726
  • Please answer the question fully in the answer. Only providing links to outside sources is frowned upon.
  • This is not correct: the question demonstrates that it works in Google Chrome but not in Firefox.