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]
- Project narrative revisions
- Timing Functions (below)
- Chapter 7: Slides 1–9
- Chapter 10: Slides 27–30
- FetchPostman.pdf: courtesy of Dr. Isaac Wang
Activity [40 min]
- Hoppscotch
- Work on your project after you finish
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);