30 Days of Code: Common Mistakes in JavaScript

🚀 30 Days — 30 Coding Mistakes Beginners Make Day 11/30 I called an API… and console printed: Promise { <pending> } 😐 My code looked fine: const res = fetch(url) const data = res.json() The mistake: I forgot `await`. `fetch()` does not return data. It returns a Promise. So I was logging the Promise — not the response. Fix 👇 const res = await fetch(url) const data = await res.json() Async code needs time. `await` tells JavaScript to wait for the result. Day 12 tomorrow 👀 #30DaysOfCode #javascript #reactjs #frontend #webdevelopment #codeinuse

  • graphical user interface

To view or add a comment, sign in

Explore content categories