27 lines783 B

Lesson 7: fetch and promises

We look at fetch and promises the way working developers use it, with examples you can change and run straight away.

Read the full lesson: https://glibcode.net/courses/javascript-web/lessons/7

Files

  • fetch.js: fetch with then() and error handling

Tip: Optional chaining saves a lot of ifs: user?.address?.city.

Tip: console.table(array) is much easier to read than console.log for lists of objects.

Tip: The browser's Network tab shows every fetch with its status and response.

Tip: Use === unless you have a reason not to.

Run it

node fetch.js

Exercises

See exercises.md. Ask in the forum once you've tried.