StoicBuilder
Later missionMission 6: Why the spinner comes firstYou can practise it now. It counts once you reach mission 6, after “Cancel that didn't cancel”.Back to HQ
Exit lesson
AsyncProLesson 9 of 45, about 5 min
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
0 XP

The app: Chirp

ChirpHome

Nothing here yet. Press Refresh to load your feed.

The data behind it

feed.js runs when you press Refreshnot run yet
1async function loadFeed() {2 setLoading(true);3 const res = await fetch("/api/feed");4 const posts = await res.json();5 setPosts(posts);6 setLoading(false);7}
state what the screen reads
{ "loading": false, "error": null, "posts": [] }
Console what happened, in order
Nothing yet.

The MagisterChirp doesn’t have the posts yet. It has to ask its server, and the answer takes time to travel. Press Refresh. While you wait, watch line 3: the code is paused at await until the answer arrives.

Step 1 of 7Press Refresh and wait for the posts
  • The posts arrived

You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.