Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruction perhaps needed to address async issue running exercise code on local computer #1

Open
f0dder1024 opened this issue Jul 22, 2023 · 0 comments

Comments

@f0dder1024
Copy link

f0dder1024 commented Jul 22, 2023

Great content. While following along with the lecture locally I noticed.

The later sample code in the exercises (code.js) that have async content may throw the following error:
SyntaxError: await is only valid in async functions and the top level bodies of modules

This might befuddle beginners to JavaScript who are not familiar with promises. I've been modifying code.js to using an IIFE like so and running code.js on the terminal with node.

( async () => {
[ original content of code.js here]
})();

node code.js

Alternatively a function
const main = async () => {
[ original content of code.js here ]
}
main();

node code .js

@f0dder1024 f0dder1024 changed the title Instruction needed to address async issue running code on local computer Instruction perhaps needed to address async issue running exercise code on local computer Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant