rules of hooks

the fetch() function

fetch() in action

index.html

Screenshot 2026-01-13 at 2.19.19 AM.png

Screenshot 2026-01-13 at 2.43.40 AM.png

script.js

Screenshot 2026-01-13 at 2.21.36 AM.png

  1. performs console.log(”Another…”)
  2. contacts Fetch API (Browser API that is external and separate from JavaScript)
    1. rather than waiting for the Fetch API to return the information, it keeps on executing the code that comes after
  3. performs console.log(”Our valued…”)
    1. in the meantime, Fetch API requests data from randomuser.me (third party web based API)
    2. randomuser.me sends data in JSON format
  4. performs console.log(data)

fetching data via hooks

fetch() + useEffect hook in action