Skip to content

Apr 02: Fetch from API

Learning Objectives

After today’s class, you should be able to:

  • Describe positioning modes: absolute, fixed, relative, and sticky.
  • Make requests to a third-party API using Hoppscotch and fetch().
  • Handle successful and unsuccessful responses from API requests.

Lesson Outline

Lecture [35 min]

Activity [40 min]

Feedback (during Activity)

  • 40 min / 13 teams = 3 min per team
  • Would any solo teams like to merge?
    • 6 teams with 1 student
    • 5 teams with 2 students
    • 2 teams with 3 students

Timing Functions

// prints "Hello every 2 seconds" indefinitely
const intervalId = setInterval(() => {
    console.log("Hello every 2 seconds");
}, 2000);

// prints "Hello after 5 seconds" once
const timeoutId = setTimeout(() => {
    console.log("Hello after 5 seconds");

    // Clear the interval after the timeout executes
    clearInterval(intervalId);
}, 5000);

Before Tuesday

  1. Finish the reading from Prep 9.
  2. Submit Lab 8 on Gradescope. ← Due Mon at 11:59pm
  3. Make progress on Project 2 in your teamXX repository.