fcc-learn-http-assets
fcc-learn-http-assets copied to clipboard
Instruction perhaps needed to address async issue running exercise code on local computer
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