Jay Patel’s Post

Day 5 When I was a junior dev, this line of code confused the hell out of me: const response = await fetch(url) const data = await response.json() I kept asking — why TWO awaits? Why can't fetch just give me the data directly? So I stopped copy-pasting and went back to first principles. Here's what I learned: → 200 OK does NOT mean the data arrived. It just means the server is saying, "I got your request, here comes the response." The connection is still open. The body is still travelling through the wire. → fetch() returns a promise for the headers first. That's the first await — waiting for the server to respond and say "200 OK." → response.json() returns a second promise for the body. That's the second await — waiting for all the actual data to arrive and parse. Think of it like a phone call. When someone picks up and says "hello" — that's the 200. But you haven't heard the actual message yet. You wait. They speak. Now you have the data. Once I understood THAT — promises stopped feeling scary. I stopped seeing async/await as magic syntax. I started seeing it as: "wait here until the data actually arrives." First principles thinking didn't just teach me promises. It changed how I debug, how I read docs, and how I learn anything new in tech. Stop memorising patterns. Start asking WHY they exist. That one question will make you a better developer faster than any tutorial. — — — What concept finally clicked for you when you went back to first principles? Drop it in the comments 👇 #JavaScript #WebDevelopment #Promises #AsyncAwait #JuniorDeveloper #FirstPrinciples #Programming #SoftwareEngineering #TechCommunity #CodingTips #LearnToCode #NodeJS #Frontend #Backend #Developer

  • A dark-themed code editor showing async await syntax in JavaScript

To view or add a comment, sign in

Explore content categories