Day 10/100 of JavaScript 🚀 Today’s topic : Fetch API "fetch" is used to make HTTP requests in JavaScript and is a modern replacement for XMLHttpRequest Basic usage : fetch("https://lnkd.in/gCA7VyNQ") .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err)); Using async/await : async function getData() { try { const res = await fetch("https://lnkd.in/gCA7VyNQ"); const data = await res.json(); console.log(data); } catch (err) { console.error(err); } } What it does : - Returns a Promise - Cleaner than XMLHttpRequest - Works well with async/await #Day10 #JavaScript #100DaysOfCode
JavaScript Fetch API Basics and Usage
More Relevant Posts
-
Day 12/100 of JavaScript 🚀 Today’s topic: async / await "async" and "await" provide a cleaner way to work with Promises and write asynchronous code that looks like synchronous code 📍Basic example async function getData() { const res = await fetch("https://lnkd.in/gCA7VyNQ"); const data = await res.json(); console.log(data); } 📍With error handling async function getData() { try { const res = await fetch("https://lnkd.in/gCA7VyNQ"); const data = await res.json(); console.log(data); } catch (err) { console.error(err); } } 🔑 Key points : - "async" makes a function return a Promise. - "await" pauses execution until the Promise resolves. - Makes code more readable than ".then()" chaining. async/await simplifies handling asynchronous operations while still using Promises under the hood. #Day12 #JavaScript #100DaysOfCode
To view or add a comment, sign in
-
What To Know in JavaScript (2026 Edition). Part 1. Iterator Helpers (lazy data processing) JavaScript introduced Iterator Helpers — methods like .map(), .filter(), .take() directly on iterators. The goal is to avoid unnecessary intermediate arrays and improve performance. Instead of chaining operations that create arrays at every step, you get: → less memory usage → fewer computations → more predictable performance #frontend #webdev #javascript #performance
To view or add a comment, sign in
-
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Maps and Sets in JavaScript: A Deep Dive JavaScript provides several ways to store and manage data, with objects and arrays being the most commonly used structures. However, when dealing with unique values or key-value pairs with better effi Read more → https://lnkd.in/dvP2-4nH #TheCampusCoders #Tech #Developers #WebDev
To view or add a comment, sign in
-
Day 3 of My JavaScript Journey Today, I learned about JavaScript data types and how to define variables. JavaScript has two main types of data: Primitive data types: These include 7 types such as number, string, boolean, null, undefined, symbol, and bigint. Object: used to store more complex data. I also learned three ways to declare variables in JavaScript: • let • const • var One key thing I understood: "const" should be used by default, "let" when the value needs to change, and "var" is mostly outdated. Example: const name = "John"; let age = 20; Key takeaway: Understanding data types and variable declarations is fundamental to writing clean and predictable JavaScript code. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗶𝗻 𝟮𝟬𝟮𝟲 JavaScript changed. Tools are better now. You still fall into old traps. Avoid these 5 mistakes. - Top-level await It is risky in libraries. It creates race conditions. Use a singleton pattern. This protects your bundle size. - The == operator Stop using ==. It uses confusing logic. It ruins type safety. Use === for all checks. - let in async loops let is block-scoped. Async loops capture live values. Your logs will show the same number. Use a const inside the loop. - The this keyword Arrow functions do not bind this. They use the outer scope. This leads to undefined. Use regular functions for methods. - JSON and Dates JSON.parse returns strings. It does not create Date objects. Your code will crash. Use a reviver function. Source: https://lnkd.in/g4yDDjNe
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