fcc-learn-http-assets icon indicating copy to clipboard operation
fcc-learn-http-assets copied to clipboard

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

Open f0dder1024 opened this issue 1 year ago • 0 comments

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 avatar Jul 22 '23 16:07 f0dder1024