# express.json() significance? 1) The one line that makes your backend actually work. 2) You write your POST route. You send data from frontend. You console.log(req.body). >>>undefined. - No error. No clue. Just silence. 3) Here's what's happening: Your frontend sends JSON, but Express receives it as a raw stream of bytes. It has no idea what to do with it. express.json() is the middleware that reads that stream, sees Content-Type: application/json, parses it, and puts it on req.body. // Without it req.body → undefined // With it req.body → { name: "myName", email: "myEmail@gmail.com" } #ExpressJS #NodeJS #JavaScript #Backend #MERN #WebDevelopment
Express JSON Middleware Explained
More Relevant Posts
-
REST APIs — Explained for Frontend Developers When building web applications, the frontend does not directly communicate with the database. It communicates with a backend server through APIs. This post covers the basics of REST APIs: • What an API is • What REST means • HTTP methods (GET, POST, PUT, DELETE) • Request and Response • Status codes • JSON data format • How frontend, backend, and database connect Understanding APIs is essential for building real-world applications, because this is how the frontend and backend communicate. 📌 Save this for revision. #WebDevelopment #FrontendDeveloper #BackendDevelopment #JavaScript #React #NodeJS #RESTAPI #LearningInPublic #Consistency
To view or add a comment, sign in
-
Node.js is fast. Until it’s not. Most performance issues I see are not because of Node.js… they’re because of how it’s used. Common mistakes: - Running heavy tasks inside request handlers - No caching for repeated data - Poor database queries - Too many sequential awaits Node is great for handling thousands of requests. But it expects you to respect one thing the event loop. If you block it, everything slows down. If you use it correctly, it scales beautifully. The difference is not the stack. It’s the engineering behind it. Have you ever faced performance issues in Node.js? What was the cause? #nodejs #backend #performance #webdevelopment #javascript
To view or add a comment, sign in
-
Ever wondered how everything on the web comes together? Here’s a quick breakdown: 🔹 Frontend — What users see (HTML, CSS, JavaScript) 🔹 Frameworks — Build smarter UIs (React / Vue) 🔹 Backend — Logic & processing (Node.js, Express) 🔹 Database — Where data lives (MySQL / MongoDB) 🔹 APIs — The bridge that connects it all Understanding these layers is the first step toward becoming a solid developer. 💡 Whether you're just starting or brushing up your basics, mastering the fundamentals always pays off. #WebDevelopment #Frontend #Backend #FullStack #JavaScript #Coding #Tech #Developers
To view or add a comment, sign in
-
-
🚀 Day 1 of Backend Journey — Serving Static Files in Express.js Today I learned how to serve static files like HTML, CSS, JavaScript, and images using Express.js. 📁✨ 🔹 Key Learnings: - What static files are and why they matter - Using "express.static()" middleware - Organizing assets inside a public folder - Linking static files with EJS templates 💡 Insight: Serving static files efficiently improves performance and reduces server load, making applications faster and more scalable. 📌 Every small concept is a step toward becoming a better backend developer! #BackendDevelopment #NodeJS #ExpressJS #WebDevelopment #LearningJourney #100DaysOfCode
To view or add a comment, sign in
-
-
⚡ Stop Killing Performance — 3 Ways to Reduce React Rerenders React is fast. Bad code isn't. 1. React.memo for expensive components const ExpensiveComponent = React.memo(({ data }) => { // Only rerenders when data changes }); 2. useCallback for functions passed as props const handleClick = useCallback(() => { doSomething(id); }, [id]); // New function only when id changes 3. useMemo for expensive calculations const sortedData = useMemo(() => { return data.sort((a, b) => a.value - b.value); }, [data]); // Only recalculates when data changes The Impact: Cut rerenders by 60% on a recent dashboard. User interactions went from laggy to instant. What's your React performance tip? #ReactJS #WebPerformance #FrontendDeveloper #JavaScript #CodingTips
To view or add a comment, sign in
-
If you’re writing 5 files just to toggle a boolean... 🛑 You’re not scaling. You’re over-engineering. For a long time, I used Redux for almost everything in React. And honestly? It felt powerful... but also unnecessarily complex for 90% of my use cases. Recently, I switched to Zustand — and the difference is 🔥 Why Zustand just makes sense: ✅ Zero Boilerplate No Providers. No massive folder structures. Just create and use. ✅ Hook-Based If you know useState, you already understand Zustand. It feels like native React. ✅ Performance First It handles selective re-renders out of the box. Only the components that need the data will update. 💻 The "Store" is this simple: JavaScript import { create } from 'zustand' const useStore = create((set) => ({ count: 0, inc: () => set((state) => ({ count: state.count + 1 })), })) Use it anywhere: JavaScript function Counter() { const { count, inc } = useStore() return <button onClick={inc}>{count}</button> } ⚡ 𝗣𝗥𝗢 𝗠𝗢𝗩𝗘 (Most developers miss this): Use selectors to grab only what you need: const count = useStore((state) => state.count) This keeps your app lightning-fast even as your state grows massive. 📈 Since switching, my code is: → Simpler → Cleaner → Easier to maintain 🟣 Team Redux (The tried and true) 🐻 Team Zustand (The minimalist) #ReactJS #Zustand #JavaScript #WebDevelopment #Frontend #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
-
Node.js is single-threaded. So why doesn’t your server freeze with 10,000 requests? This confused me for months — until I understood the event loop. Here’s the mental model that made it click The 4 pieces you need to understand 1. JS Engine (e.g. V8) Executes your JavaScript by parsing → compiling → running it, while managing memory (heap) and execution flow (call stack) 2. Call Stack A single-threaded execution stack where synchronous code runs one function at a time — if it’s occupied by heavy work, nothing else (including callbacks) can run 3. Web APIs / Node APIs (libuv) Background system that takes over async operations (timers, file system, network, DB), so the JS engine doesn’t block while waiting 4. Queues Hold ready callbacks — microtasks (Promises) are processed immediately after current execution, while task queue (timers/I/O) runs only when the stack is free 🔁 The rule everything follows 1. Run all synchronous code (call stack) 2. Execute ALL microtasks (Promises) 3. Execute ONE task (timers, I/O) 4. Repeat 🍽️ Mental model Node is a single chef Takes orders (requests) Hands off long work (async APIs) Keeps working instead of waiting Comes back when tasks are ready ⚠️ If the chef is stuck → everything stops #nodejs #javascript #nestjs #backend #softwareengineering
To view or add a comment, sign in
-
-
⚙️ From a Single Click to a Complete System Flow 🎯 At first glance, it feels simple: 👉 Click → API → Data → UI ❌ Reality? Not even close. ⚙️ A single action flows through: 🧠 Frontend logic → 🌐 API call → 🛡️ Middleware → 🛣️ Routes → 🎯 Controller → 🧩 Service → 🗄️ Database → 📦 Response → 🔄 State → 🎨 Re-render 💡 Here’s the truth: If your logic lives only inside controllers, you’re setting yourself up for ⚠️ messy, unscalable code. 🧱 Good developers make it work. 🏗️ Great developers make it structured. #MERNStack #FullStackDeveloper #BackendDevelopment #WebDevelopment #ReactJS #NodeJS #ExpressJS #MongoDB #JavaScript #SoftwareEngineering #SystemDesign #CleanCode #APIDevelopment #BuildInPublic #DevCommunity
To view or add a comment, sign in
-
-
JavaScript Closures are confusing… until they’re not ⚡ Most developers memorize the definition but struggle to actually understand it. Let’s simplify it 👇 💡 What is a closure? A closure is when a function 👉 remembers variables from its outer scope even after that scope is finished 🧠 Example: function outer() { let count = 0; return function inner() { count++; console.log(count); }; } const fn = outer(); fn(); // 1 fn(); // 2 fn(); // 3 ⚡ Why this works: inner() still has access to count even after outer() has executed 🔥 Where closures are used: • Data hiding • State management • Event handlers • Custom hooks in React #JavaScript #FrontendDeveloper #ReactJS #CodingTips #WebDevelopment
To view or add a comment, sign in
-
🚀 How Frontend & Backend Work When We Open a Website in Browser Point 1: Browser Request When we enter a website URL in the browser and press Enter, the browser sends a request to the server where the website is hosted. Point 2: DNS Resolution Before connecting to the website, the browser uses DNS to convert the domain name into an IP address. Example: google.com → server IP address Point 3: Frontend Files Load The server sends the files required to display the UI: HTML → structure CSS → styling JavaScript → functionality images / icons / fonts Point 4: UI Rendering in Browser The browser reads these files and creates the page UI: HTML creates the DOM CSS styles the page JavaScript adds interactivity Point 5: React App Loading In React, the JavaScript bundle loads first, and then React renders components inside the root div. Point 6: Frontend Calls Backend Once the UI is visible, the frontend sends API requests to get dynamic data like user details, products, or orders. Example: fetch('/api/products') Point 7: Backend Processing The backend receives the request, applies business logic, validations, authentication, and other processing. Common technologies: Node.js Java Spring Boot Point 8: Database Interaction The backend fetches or stores data in databases such as: MySQL PostgreSQL MongoDB Point 9: Response to Frontend The backend sends the response back to the frontend in JSON or API response format. Point 10: UI Update The frontend receives the data and updates the UI dynamically without reloading the full page. Complete Flow Browser → Frontend → Backend → Database → Response → UI Update #ReactJS #FrontendDeveloper #Backend #WebDevelopment #JavaScript
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