Skip to content

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

Open
@f0dder1024

Description

@f0dder1024

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions