🚨 Most developers use Fetch… but still get it wrong Not because it’s hard— but because of ONE hidden detail 👇 👉 Fetch does NOT fail on HTTP errors So even if your API returns: ❌ 404 ❌ 500 Your code still runs like everything is fine 😬 💡 The fix? Always check res.ok before using the data 🔥 Key takeaway: Fetch = Promise-based NOT = automatic error handling This tiny mistake can break real apps Save this before your next interview 🚀 Have you run into this before? 👇 #JavaScript #Frontend #WebDevelopment #CodingTips #Developers
Fetch API Error Handling Gotcha in JavaScript
More Relevant Posts
-
We scanned 𝗥𝗲𝗮𝗰𝘁.𝗷𝘀. Used by millions of developers worldwide. 𝟭𝟰𝟯 𝗶𝘀𝘀𝘂𝗲𝘀. 81 of them critical. 🔴 Here's what shocked us: 🔴 XSS vulnerability - user uploaded files reflected without sanitization 🔴 Code injection via eval() - arbitrary code execution possible 🔴 Missing authentication on POST endpoints 🔴 Path traversal - attackers can overwrite system files 🔴 Secrets exposed to client via environment variables This is not some unknown side project. This is the framework your entire frontend probably runs on. We are not saying React is broken. We are saying - no codebase is perfect. Not even the ones you trust the most. That's exactly why code scanning exists. Not to blame. Not to scare. But to know. Because the earlier you find it, the cheaper it is to fix. Full report in first comment 👇 #ReactJS #JavaScript #WebSecurity #CodeReview #Relia #BuildInPublic #OpenSource #Developer
To view or add a comment, sign in
-
-
We scanned 𝗥𝗲𝗮𝗰𝘁.𝗷𝘀. Used by millions of developers worldwide. 𝟭𝟰𝟯 𝗶𝘀𝘀𝘂𝗲𝘀. 81 of them critical. 🔴 Here's what shocked us: 🔴 XSS vulnerability - user uploaded files reflected without sanitization 🔴 Code injection via eval() - arbitrary code execution possible 🔴 Missing authentication on POST endpoints 🔴 Path traversal - attackers can overwrite system files 🔴 Secrets exposed to client via environment variables This is not some unknown side project. This is the framework your entire frontend probably runs on. We are not saying React is broken. We are saying - no codebase is perfect. Not even the ones you trust the most. That's exactly why code scanning exists. Not to blame. Not to scare. But to know. Because the earlier you find it, the cheaper it is to fix. Full report in first comment 👇 #ReactJS #JavaScript #WebSecurity #CodeReview #Relia #BuildInPublic #OpenSource #Developer
To view or add a comment, sign in
-
-
Stop writing boilerplate API routes! 🛑 React Server Actions are fundamentally changing how we think about the 'Fullstack' boundary. We are moving away from the manual fetch/useEffect cycle and moving toward direct, type-safe server function calls. Why this is a breakthrough for your workflow: ✅ Zero API route overhead: Call functions, not endpoints. ✅ End-to-end Type Safety: TypeScript follows your data from the database to the UI. ✅ Progressive Enhancement: Forms work even before JavaScript hydrates. ✅ Reduced Client Bundle: Server logic stays on the server. Is the traditional REST API approach dying for modern web apps, or is this just making our developer experience smoother? 👇 #ReactJS #NextJS #WebDevelopment #Fullstack #JavaScript #TypeScript #Frontend #Backend #SoftwareEngineering #Programming #WebDev #ReactServerComponents #Coding #TechTrends #ModernWeb #SoftwareArchitecture #Vercel
To view or add a comment, sign in
-
-
⚡ Part 6 of 10: React performance conversations often start too early. Someone sees a rerender and immediately reaches for memoization. But sometimes the real issue is simpler than that. Bad state shape. Too much work inside render. Unclear data flow. A component tree that grew without much intention. I’m not against optimization. I just think the better starting point is: What actually feels slow? Where’s the bottleneck? What problem are we solving? A lot of React code gets more complicated in the name of performance without actually getting better. Have you ever seen “performance optimization” make a codebase worse? #React #ReactPerformance #FrontendPerformance #JavaScript #TypeScript #SoftwareEngineering #WebPerformance
To view or add a comment, sign in
-
Closures used to confuse me a lot… until today 💡 Now I realize it's just about a function remembering its data. Simple idea, powerful use. If you're learning JavaScript, don’t skip this 🚀 💬 Do closures make sense to you now? #JavaScript #WebDevelopment #Frontend #CodingJourney #Developers
To view or add a comment, sign in
-
-
Stop writing React like it's 2021. 🛑 The ecosystem has evolved. If you want a cleaner, more performant codebase, it is time to upgrade your patterns: 🔄 Data Fetching: useEffect ❌ TanStack Query ✅ 🧠 Global State: Context API ❌ Zustand ✅ 📝 Forms: useState / useRef spam ❌ React Hook Form / React 19 Actions ✅ ⚡ Performance: useMemo / useCallback ❌ React Compiler ✅ 🎨 Styling: CSS-in-JS / bloated SCSS ❌ Tailwind CSS ✅ 🛡️ Validation: Manual checks & any ❌ Zod + TypeScript ✅ Less boilerplate. Fewer unnecessary re-renders. Better developer experience. What is a tool or pattern you finally stopped using this year? 👇 #ReactJS #WebDevelopment #Frontend #TypeScript #TailwindCSS
To view or add a comment, sign in
-
🚨 "async/await" makes asynchronous code look simple… But it’s also one of the easiest ways to introduce subtle bugs. Over the years, I’ve seen (and made) these mistakes more times than I’d like to admit. Here are some of the most common "async/await" mistakes that can cause real production issues 👇 💡 1. Forgetting to use "await" const data = fetch('/api/users'); // Promise, not actual data console.log(data); ✅ Correct: const data = await fetch('/api/users'); 💡 2. Using "await" inside loops unnecessarily for (const id of ids) { const user = await fetchUser(id); } This runs sequentially and can be painfully slow. ✅ Better: const users = await Promise.all(ids.map(fetchUser)); 💡 3. Missing error handling const data = await fetchData(); If the request fails, your app may crash. ✅ Always wrap critical async calls: try { const data = await fetchData(); } catch (error) { console.error(error); } 💡 4. Mixing ".then()" with "await" const data = await fetch(url).then(res => res.json()); It works, but it’s inconsistent and harder to read. ✅ Prefer one style: const res = await fetch(url); const data = await res.json(); 💡 5. Awaiting independent tasks one by one const user = await fetchUser(); const posts = await fetchPosts(); These can run in parallel. ✅ Better: const [user, posts] = await Promise.all([ fetchUser(), fetchPosts() ]); 💡 6. Not handling rejected promises in "Promise.all()" If one promise fails, the entire batch fails. 👉 Use "Promise.allSettled()" when partial success is acceptable. 🔥 "async/await" improves readability — but understanding how it behaves is what makes your code truly reliable. #JavaScript #JS #es6 #react #reactjs #AsyncAwait #WebDevelopment #Frontend #Programming #SoftwareEngineering
To view or add a comment, sign in
-
Unpopular opinion: most Web performance optimization — Core Web Vitals strategies that work tutorials are teaching you the wrong thing. They teach syntax. They should teach systems thinking. The difference between a junior and senior developer isn't knowing more APIs. It's knowing which problems are worth solving and which to delegate — to a teammate, a library, or an AI. What's the most valuable lesson you've learned that no tutorial ever taught you? #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
Unpopular opinion: most Web performance optimization — Core Web Vitals strategies that work tutorials are teaching you the wrong thing. They teach syntax. They should teach systems thinking. The difference between a junior and senior developer isn't knowing more APIs. It's knowing which problems are worth solving and which to delegate — to a teammate, a library, or an AI. What's the most valuable lesson you've learned that no tutorial ever taught you? #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
Search UIs often break when slower responses arrive late and overwrite fresher input. Use AbortController to cancel in-flight fetch calls before sending the next one. This removes race-condition flicker and reduces API waste. Mini pattern: abort previous controller → create new controller → pass signal to fetch. #javascript #webdev #frontend #codingtips #softwareengineering
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development