Stop Messing With APIs: How fetch() and .json() Actually Work
Imagine you’re in NASA mission control. Artemis 2 is about to launch — humanity’s next giant leap in space. Engineers and scientists are buzzing, every system needs to work perfectly. Now, imagine ...

Source: DEV Community
Imagine you’re in NASA mission control. Artemis 2 is about to launch — humanity’s next giant leap in space. Engineers and scientists are buzzing, every system needs to work perfectly. Now, imagine you’re the coder responsible for getting live telemetry from that spacecraft. If you don’t understand how data travels, how it’s formatted, or how to handle it, you’re in serious trouble. Welcome to the world of fetch() and .json() — your mission control for API data. Look at This Code fetch("https://api.openweathermap.org/data/2.5/weather?q=Chennai&appid=YOUR_API_KEY&units=metric") .then(res => res.json()) .then(data => console.log(data)); Looks small and simple, right? But every part is like a critical system on Artemis 2. Skip one step, and your code could “crash” — or worse, give you garbage data. Step 1: fetch() — Launching the Rocket fetch(URL) This is your launch command. You ask the server: “Give me the latest Chennai weather.” Immediately, you get a Promise Think of it