Closed bbrown-spsu closed 3 years ago
As pointed out by @bbrown-spsu this is because of an await
that is not in an async
function.
What is the general rule when it come's to cases like this? Do we wrap it with an async
iife (would probably bloat the code samples)? Do we assume that users will understand that they have to put it in an async
function? Any other options?
Worth pointing out that this is not an example that is meant to be run from withing the page like interactive-examples
, but rather its a code sample.
A couple of thoughts...
I think the very minimum change would be a comment before the call: // The code below must itself be within an async function.
Better would be a real async function (not iife) called by a non-async function, in other words, something that could be clipped out and run. It would double the length of the example, but more than double the usefulness of the example.
I would be happy for you to fix them up so they are runnable at a basic level. I agree with @bbrown-spsu here, and async/await is still fairly new.
Issue moved to mdn/content #1443 via ZenHub
Request type
Details
The examples on this page will not run in Firefox 83.0 64 bit. That appears to be because "await" is not within an async function on the next-to-last line. The message I get is "Uncaught SyntaxError: await is only valid in async functions and async generators"
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest