JavaScript Feature: Fetch API The Fetch API is a modern way to make HTTP requests in JavaScript. It’s promise-based, making it cleaner and easier than the old XMLHttpRequest. Basic Usage: fetch('https://lnkd.in/gWKpgMrT') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); fetch() returns a Promise. response.json() parses the response into JSON. .catch() handles errors gracefully. Using Async/Await for Cleaner Syntax: async function getData() { try { const response = await fetch('https://lnkd.in/gWKpgMrT'); const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); } } getData(); Pro Tips: Always handle network errors. Use headers for authentication or content-type. Can be used for GET, POST, PUT, DELETE requests. The Fetch API is powerful, modern, and essential for building dynamic web apps! #JavaScript #FetchAPI #AsyncProgramming #WebDevelopment #Frontend #Promises #AsyncAwait #CodingTips #CleanCode
Sameer Basha Shaik’s Post
More Relevant Posts
-
Front-End (Client Side) HTML → Structure Like the skeleton of a human body, HTML provides the basic structure of a webpage — the bones that everything else is built on. CSS → Presentation Just as clothes and appearance define how a person looks, CSS styles and beautifies the web page, handling colors, layouts, and fonts. JavaScript → Behaviour Represents how a person acts or moves. JavaScript brings a webpage to life by adding interactivity, animations, and logic. Back-End (Server Side) Node.js → Brain Works like the brain, controlling the logic and making decisions on the server side. It processes user requests and manages operations. MySQL → Memory Just like memory stores information in a brain, MySQL stores and retrieves data for the web application. Express.js → Nervous System Acts as the communication link between different parts of the body. Similarly, Express.js connects routes and middleware, managing requests and responses in a Node.js application. React/Vue → Personality Defines how the user interacts and perceives the system. React or Vue gives the frontend its dynamic, interactive personality. REST API → Communication Like the way humans communicate with each other, APIs allow different applications or services to exchange data and interact smoothly. #FullStack #MERN #WebDevelopment #JavaScript #ReactJS #NodeJS #ExpressJS #MongoDB #VersionControl #Git #GitHub #Coding #TechCareer #SoftwareEngineering #Frontend #Backend #DeveloperJourney #CareerGrowth #Html #Css #JavaScript #MySQL
To view or add a comment, sign in
-
-
⚛️ React 19 – New & Updated Hooks use() → Lets you directly use async data or promises inside components without useEffect, simplifying data fetching. 🧠 Example: const user = use(fetchUser()); useOptimistic() → Makes optimistic UI updates easy by letting you show temporary data before the server confirms changes. 🧠 Example: Instantly add a todo to the list before it’s saved. useActionState() → Manages form state, submission, and errors in one place, making form handling cleaner. 🧠 Example: Handle loading and validation directly with one hook. useFormStatus() → Gives real-time status of a form (like pending or submitted) during server actions. 🧠 Example: Disable the submit button while the form is sending data. useDeferredValue() (from React 18) → Defers rendering of slow components to keep the UI responsive. 🧠 Example: Smooth typing experience during heavy data filtering. useTransition() (from React 18) → Allows marking state updates as non-urgent, improving perceived performance. 🧠 Example: Show loading spinner while background updates happen. React 18 improved performance with concurrent rendering and transitions, React 19 makes async data and forms simpler and more intuitive with use(), useOptimistic(), and useActionState(). #react #reactjs #nextjs #javascript #frontend
To view or add a comment, sign in
-
Build Library Management System Using React, Shadcn/ui, Supabase, Tanstack Query(React Query)🚀 11+ hours of video content⚡️ What you will learn: ✅ How to build an application from scratch in a step-by-step way ✅ How to work with Supabase from scratch ✅ How to 𝘀𝗲𝗮𝗿𝗰𝗵 𝘁𝗵𝗿𝗼𝘂𝗴𝗵 𝗦𝘂𝗽𝗮𝗯𝗮𝘀𝗲 𝗱𝗼𝗰𝘂𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 to implement anything you need ✅ How to create better folder and file structure to better organize code ✅ How to easily implement a 𝗱𝗮𝘁𝗮 𝗴𝗿𝗶𝗱 𝘄𝗶𝘁𝗵 𝗽𝗮𝗴𝗶𝗻𝗮𝘁𝗶𝗼𝗻, 𝗳𝗶𝗹𝘁𝗲𝗿𝗶𝗻𝗴, 𝗮𝗻𝗱 𝘀𝗼𝗿𝘁𝗶𝗻𝗴 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝗮𝗹𝗶𝘁𝘆 ✅ How to work with 𝗧𝗮𝗻𝘀𝘁𝗮𝗰𝗸 𝗤𝘂𝗲𝗿𝘆 (𝗥𝗲𝗮𝗰𝘁 𝗤𝘂𝗲𝗿𝘆) & 𝗦𝗵𝗮𝗱𝗰𝗻/𝘂𝗶 from scratch ✅ How to write better code using 𝗰𝘂𝘀𝘁𝗼𝗺 𝗵𝗼𝗼𝗸𝘀 ✅ How to add a 𝘀𝗸𝗲𝗹𝗲𝘁𝗼𝗻 𝗹𝗼𝗮𝗱𝗶𝗻𝗴 𝗲𝗳𝗳𝗲𝗰𝘁 while loading the image ✅ How to quickly implement 𝗟𝗼𝗴𝗶𝗻, 𝗥𝗲𝘀𝗲𝘁 𝗣𝗮𝘀𝘀𝘄𝗼𝗿𝗱, 𝗘𝗺𝗮𝗶𝗹 𝗦𝗲𝗻𝗱𝗶𝗻𝗴 functionality Using Supabase ✅ How to create dynamic custom modals without re-writing the same code again ✅ How to 𝗯𝘂𝗶𝗹𝗱 𝗰𝗵𝗮𝗿𝘁𝘀 from scratch ✅ How to 𝘂𝗽𝗹𝗼𝗮𝗱 𝗶𝗺𝗮𝗴𝗲𝘀 𝘁𝗼 𝗦𝘂𝗽𝗮𝗯𝗮𝘀𝗲 ✅ How to 𝗯𝘂𝗶𝗹𝗱 𝗿𝗲𝘀𝗽𝗼𝗻𝘀𝗶𝘃𝗲 𝗮𝗽𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻 using Tailwind CSS ✅ Various tips, tricks and better coding practices ✅ And the most important thing - 𝗛𝗼𝘄 𝘁𝗼 𝗱𝗲𝗽𝗹𝗼𝘆 𝘁𝗵𝗲 𝗮𝗽𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝘁𝗼 𝗽𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻 𝘀𝘁𝗲𝗽-𝗯𝘆-𝘀𝘁𝗲𝗽 𝗖𝗵𝗲𝗰𝗸 𝗼𝘂𝘁 𝘁𝗵𝗲 𝗙𝗥𝗘𝗘 𝗽𝗿𝗲𝘃𝗶𝗲𝘄 𝘃𝗶𝗱𝗲𝗼𝘀 𝗼𝗻 𝘁𝗵𝗲 𝗰𝗼𝘂𝗿𝘀𝗲 𝗽𝗮𝗴𝗲. 𝗣𝗦: 𝗗𝗼𝗻'𝘁 𝗳𝗼𝗿𝗴𝗲𝘁 𝘁𝗼 𝗰𝗵𝗲𝗰𝗸 𝗼𝘂𝘁 𝘁𝗵𝗲 𝗺𝗮𝘀𝘀𝗶𝘃𝗲 𝗼𝗳𝗳𝗲𝗿 𝗼𝗳 𝟵𝟯% 𝗱𝗶𝘀𝗰𝗼𝘂𝗻𝘁 𝗼𝗻 𝘁𝗵𝗲 𝗣𝗿𝗼 / 𝗟𝗶𝗳𝗲𝘁𝗶𝗺𝗲 𝗦𝘂𝗯𝘀𝗰𝗿𝗶𝗽𝘁𝗶𝗼𝗻. 𝗟𝗶𝗻𝗸 𝗶𝗻 𝘁𝗵𝗲 𝗰𝗼𝗺𝗺𝗲𝗻𝘁 𝗮𝗻𝗱 𝗶𝗻 𝘁𝗵𝗲 𝗳𝗲𝗮𝘁𝘂𝗿𝗲𝗱 𝘀𝗲𝗰𝘁𝗶𝗼𝗻 𝗼𝗳 𝗺𝘆 𝗟𝗶𝗻𝗸𝗲𝗱𝗜𝗻 𝗽𝗿𝗼𝗳𝗶𝗹𝗲. #javascript #reactjs #supabase #tantackquery #webdevelopment
Build Library Management System Using React, Shadcn/ui, Supabase, Tanstack Query(React Query)
To view or add a comment, sign in
-
JavaScript Tip: Error Handling Patterns Error handling is crucial for building robust and reliable applications. JavaScript provides several patterns to catch and manage errors effectively. 1. Try…Catch Wrap code that may throw an error: try { let result = riskyOperation(); console.log(result); } catch (error) { console.error('Error caught:', error); } 2. Try…Catch…Finally finally runs regardless of success or failure, ideal for cleanup: try { performTask(); } catch (error) { console.error(error); } finally { console.log('Task finished'); } 3. Promises Catch Handle async errors with .catch(): fetchData() .then(data => console.log(data)) .catch(err => console.error('Fetch error:', err)); 4. Async/Await with Try…Catch Clean syntax for async code: async function fetchData() { try { const response = await fetch('https://lnkd.in/gWKpgMrT'); const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); } } Best Practices: Always handle both sync and async errors. Provide meaningful error messages for debugging. Use centralized error logging in production apps. Error handling is not optional—it makes your app resilient, reliable, and professional. #JavaScript #ErrorHandling #AsyncProgramming #Frontend #WebDevelopment #CodingTips #Promises #AsyncAwait #CleanCode
To view or add a comment, sign in
-
🔖React Tip: When Your “id” Isn’t Really Unique Recently ran into an interesting issue while working with API data in React. I was rendering a table and opening a popup when clicking on a cell - seemed simple enough. The API response looked like this: [ { id: "101", name: "101", age: 25 }, { id: "102", name: "102", age: 27 } ] Both `id` and `name` had the same values, and I didn’t think much of it at first. But when I opened the popup from the ID cell, it sometimes showed the wrong record or didn’t update at all. Here’s what the code looked like: {data.map((item) => ( <tr key={item.id}> <td onClick={() => openPopup(item.id)}>{item.id}</td> <td>{item.name}</td> </tr> ))} ⁉️The problem? React uses the `key` prop to identify DOM elements. If multiple rows share the same key value, React may reuse elements incorrectly. Also, since the popup logic was using `id` for lookup, it always returned the first matching record. Here’s the safer version: {data.map((item, index) => ( <tr key={index}> <td onClick={() => openPopup(item)}>{item.id}</td> <td>{item.name}</td> </tr> ))} And the popup handler: const openPopup = (rowData) => setSelected(rowData); 🧠Lesson learned: even something as small as duplicate `id` fields can cause surprising bugs in React tables. Always make sure your keys are unique and your popup or event logic doesn’t rely on repeated identifiers. #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #ReactTips
To view or add a comment, sign in
-
Use container queries so components respond to the size of their container, not the entire screen. Ultra-reusable UI. ✅ Step 1: declare a container .card { container-type: inline-size; -> enables size queries } ✅ Step 2: query the container size .product-tile { display: grid; gap: .75rem; } @container (min-width: 420px) { .product-tile { grid-template-columns: 120px 1fr; } } @container (min-width: 700px) { .product-tile { grid-template-columns: 180px 1fr; } } ✔ Truly portable components ✔ Fewer brittle media queries ✔ Works great inside grids/sidebars/cards Finally: Make the parent a container, then style children with @container rules → components adapt wherever they live. #Angular #Signals #RxJS #Reactivity #FrontendTips #WebDevelopment #JavaScript #FullStackDeveloper #CleanCode #CodingJourney #CSS #Frontend #ResponsiveDesign #UIDesign #NodeJS #ExpressJS #PostgreSQL #pgAdmin #Backend #API #FullStack
To view or add a comment, sign in
-
JavaScript doesn’t wait for anything… yet somehow, everything still gets done 😎 Ever wondered how? Master behind the screens — Promises 🔥 In JavaScript, a Promise is like saying — “I don’t have the answer yet, but I’ll get back to you once I do.” It helps JS handle async operations like fetching data, API calls, timers, and more — without blocking the main thread. let's check the below code 👇 const getData = new Promise((resolve, reject) => { const success = true; success ? resolve("✅ Data fetched") : reject("❌ Failed"); }); getData .then(res => console.log(res)) .catch(err => console.log(err)) .finally(() => console.log("Operation complete")); When you run this: First, the promise is pending ⏳ Then it becomes fulfilled ✅ or rejected ❌ But there’s more — Promises can work together too 👇 Promise.all() → Waits for all to finish (fails if one fails) Promise.allSettled() → Waits for all, even if some fail Promise.race() → Returns the fastest one to settle 🏁 Promise.any() → Returns the first successful one 🎯 In short Promises don’t make JavaScript faster. They make it smarter — letting your code do more while waiting for results 💪 #JavaScript #WebDevelopment #Frontend #MERNStack #AsyncProgramming #NodeJS #ReactJS #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
Here we go with "another one"! There's a common myth about traditional Server Side Rendering: the server builds your web page and grabs data at the same time, making everything super fast. The article below breaks down what actually happens and compares it to how regular React apps work. Spoiler: SSR might not be as fast as everyone claims. https://lnkd.in/eAjPTd6b #ReactJS #Nextjs #WebDev #SSR #CSR #JavaScript #WebPerformance #ReactJS #Nextjs #WebDev #SSR #CSR #JavaScript
To view or add a comment, sign in
-
*JavaScript Beginner Roadmap* 🌐✨ 📂 *Start Here* ∟📂 Set Up Your Environment (Browser Console, VS Code) ∟📂 Write & Run Your First JS Script 📂 *JavaScript Basics* ∟📂 Variables (`let`, `const`, `var`) ∟📂 Data Types (Number, String, Boolean, Null, Undefined, Object) ∟📂 Operators (Arithmetic, Comparison, Logical) ∟📂 Control Flow (`if`, `else`, `switch`) ∟📂 Loops (`for`, `while`, `do-while`) 📂 *Functions* ∟📂 Function Declaration & Expression ∟📂 Arrow Functions ∟📂 Parameters & Return Values ∟📂 Scope & Closures 📂 *Objects & Arrays* ∟📂 Creating & Accessing Objects ∟📂 Arrays & Array Methods (`push`, `pop`, `map`, `filter`) 📂 *DOM Manipulation* ∟📂 Selecting Elements (`getElementById`, `querySelector`) ∟📂 Changing Content & Styles ∟📂 Event Handling (`click`, `input`) 📂 *Asynchronous JavaScript* ∟📂 Callbacks ∟📂 Promises ∟📂 Async/Await 📂 *Debugging & Tools* ∟📂 Console & Breakpoints ∟📂 DevTools Basics 📂 *Practice Projects* ∟📌 Interactive To-Do List ∟📌 Simple Calculator ∟📌 Quiz App 📂 ✅ *Next Steps* ∟📂 Learn ES6+ Features ∟📂 Introduction to Frameworks (React, Vue) ∟📂 Explore APIs & Fetch Data React "❤️" for more!
To view or add a comment, sign in
-
⚡ React Tip: Use useRef When You Don’t Want Re-Renders Not every piece of data in React needs to trigger a re-render. That’s where the useRef hook shines. 💡 Think of useRef as a box that holds a value — and React doesn’t care what’s inside. It’s perfect for storing values that change but don’t affect the UI. import { useRef, useState } from "react"; function Timer() { const [count, setCount] = useState(0); const intervalRef = useRef(null); // 👈 No re-renders const start = () => { if (intervalRef.current) return; // prevent multiple intervals intervalRef.current = setInterval(() => { setCount((c) => c + 1); }, 1000); }; const stop = () => { clearInterval(intervalRef.current); intervalRef.current = null; }; return ( <div> <p>⏱️ Count: {count}</p> <button onClick={start}>Start</button> <button onClick={stop}>Stop</button> </div> ); } ✅ Why it’s awesome: 1. Doesn’t cause re-renders when updated 2. Great for storing timers, previous values, or DOM references 3. Keeps your component efficient and smooth 💭 Remember: Use useRef for mutable values that shouldn’t trigger renders. Use useState for UI values that should. How often do you reach for useRef in your projects? 👇 #ReactJS #JavaScript #WebDevelopment #FrontendTips #CodingTips #CleanCode #ReactHooks #Programming #WebDev #TechTips
To view or add a comment, sign in
Explore related topics
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