Your First Fetch
Make your first real HTTP request using the Fetch API and receive live data from a public API.
What Is fetch()?
The fetch() function is a built-in browser API for making HTTP requests. It's the modern replacement for the older XMLHttpRequest and is now the standard way to talk to servers from JavaScript. You don't need to install anything — fetch() is available in every modern browser.
At its simplest, you pass fetch() a URL, and it returns a Promise that resolves with a Response object. That Response object contains everything the server sent back: the status code, headers, and the actual data (which you still need to extract).
Think about what this means: with just one line of code — fetch("https://some-api.com/data") — your JavaScript can reach out across the internet, ask a server for information, and bring it back into your webpage. This is what makes modern web apps possible. Every time you scroll Instagram, search YouTube, or check your Gmail, fetch() (or something like it) is working behind the scenes.
fetch() is like sending a letter and waiting for a reply. You write the address (URL), drop it in the mailbox (the browser sends the request), and wait (the Promise is pending). Eventually, a reply arrives in your mailbox (the Promise resolves with a Response). But the letter is still sealed — you need to open it (.json()) to read what's inside.