You've built static pages and added interactivity. Now it's time to connect your code to the real world. In Web Development 5, you'll learn asynchronous JavaScript β the techniques that power every modern web application β and use them to fetch live data from APIs, build interactive interfaces with React, and create a dynamic creator tool that actually does something useful for your business.
This is where web development stops feeling like homework and starts feeling like building real products. The portfolio site you build here won't be a static page β it'll pull live data, update dynamically, and look like something a professional made.
JavaScript is single-threaded. It can only do one thing at a time. So how does it handle network requests, file loading, and timers without freezing the entire page? Asynchronous programming.
The Problem: Blocking Code
Imagine you ask your browser to fetch data from a server. That request might take 2 seconds. If JavaScript waited β doing absolutely nothing β for those 2 seconds, your page would freeze. Buttons wouldn't click, animations would stop, scroll would lock. That's blocking behavior, and it's unacceptable.
Asynchronous code solves this by saying: "Start this task, and I'll keep doing other things. Call me when it's done."
Callbacks: The Old Way
The original async pattern in JavaScript was callbacks β you pass a function to be called when the work finishes:
setTimeout(function() {
console.log("This runs after 2 seconds");
}, 2000);
Callbacks work, but they get ugly fast. When you need to chain async operations (fetch data, then process it, then save it), you end up with deeply nested code β called callback hell:
getData(function(data) {
processData(data, function(result) {
saveData(result, function(response) {
// Three levels deep and counting...
});
});
});
Promises: The Better Way
A Promise is an object that represents a value that doesn't exist yet but will (or won't) in the future. It has three states:
- Pending β the operation hasn't completed yet
- Fulfilled β it completed successfully, here's the value
- Rejected β it failed, here's the error
fetch("https://api.example.com/data")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Failed:", error));
The .then() chain is flat instead of nested. Each step receives the result of the previous step. .catch() handles any error in the chain. This is dramatically easier to read and debug.
Async/Await: The Modern Way
async/await is syntactic sugar on top of Promises. It makes async code look like synchronous code:
async function loadData() {
try {
const response = await fetch("https://api.example.com/data");
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Failed:", error);
}
}
The await keyword pauses execution of that function until the Promise resolves. But critically, it doesn't block the main thread β other code keeps running. The try/catch block handles errors just like synchronous code.
The Fetch API
fetch() is the built-in browser function for making HTTP requests. It returns a Promise. You'll use it constantly:
// GET request (default)
const response = await fetch("https://api.example.com/users");
const users = await response.json();
// POST request
const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "New User", email: "[email protected]" })
});
Important: fetch() only rejects on network errors, not HTTP errors. A 404 response is still a "successful" fetch. You need to check response.ok to catch HTTP errors:
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
π‘ Key Takeaway
Async/await is the standard for modern JavaScript. Learn it, use it, love it. Every API call, every data fetch, every server interaction you'll ever write uses this pattern.
π¨ Exercise 4.1: Fetch and Display Data from a Public API
Build an HTML page that fetches data from a free public API and displays it on screen:
- Choose a free API: PokΓ©API, OpenWeatherMap, or GitHub API
- Use
fetch()withasync/awaitto request data when the page loads - Parse the JSON response and display at least 5 items on the page (e.g., 5 PokΓ©mon names and images, 5 GitHub repos with star counts)
- Add a loading state ("Loading...") while the request is in progress
- Add error handling β if the API is down, show a friendly error message instead of crashing
Deliverable: An HTML file with embedded JavaScript that fetches and displays live API data. Include a screenshot of the working page.
An API (Application Programming Interface) is how two pieces of software talk to each other. When your JavaScript fetches weather data, it's using a weather API. When NiteFlirt shows your listing stats, it's using an internal API. When you post to Instagram, the app is hitting Instagram's API.
Understanding APIs turns you from someone who builds pages into someone who builds applications.
REST: The Standard
REST (Representational State Transfer) is the most common API pattern. It uses HTTP methods to perform actions on resources:
- GET β Read data. "Show me all products." No side effects.
- POST β Create data. "Add a new product." Changes the server.
- PUT β Update data. "Replace this product with new data."
- PATCH β Partial update. "Change just the price of this product."
- DELETE β Remove data. "Delete this product."
A REST API organizes resources as URLs (called endpoints):
GET /api/products β List all products
GET /api/products/42 β Get product #42
POST /api/products β Create a new product
PUT /api/products/42 β Update product #42
DELETE /api/products/42 β Delete product #42
JSON: The Language of APIs
Almost every modern API speaks JSON (JavaScript Object Notation). It looks like JavaScript objects, because it is JavaScript objects:
{
"id": 42,
"title": "Premium Audio Pack",
"price": 14.99,
"tags": ["audio", "bundle", "premium"],
"creator": {
"name": "Luna",
"verified": true
}
}
When you fetch() an API, the response is text. You call response.json() to parse it into a JavaScript object you can work with.
Authentication: Proving Who You Are
Most useful APIs require authentication. Common methods:
- API Keys β A secret string you include in your request. Simplest method. Usually passed as a query parameter or header:
?api_key=abc123 - Bearer Tokens β A token (usually from OAuth) sent in the Authorization header:
Authorization: Bearer eyJ... - OAuth 2.0 β The full flow where users log in and grant your app permission. Used by Google, Twitter, YouTube, etc.
Security rule: Never put API keys in client-side JavaScript that gets shipped to browsers. Anyone can view your source code and steal the key. API keys belong in server-side code or environment variables.
Rate Limiting & Error Handling
APIs limit how many requests you can make. Hit the limit and you'll get a 429 Too Many Requests response. Good API practice:
- Cache responses when possible β don't re-fetch data you already have
- Handle errors gracefully β show the user a message, don't let the app crash
- Check the API docs for rate limits before building your integration
- Use
response.statusto handle different HTTP status codes appropriately
π‘ Key Takeaway
APIs are the backbone of every modern web application. Mastering REST + JSON + fetch means you can integrate any service β social media, payments, analytics, AI β into your projects.
π¨ Exercise 4.2: Multi-API Dashboard
Build a simple dashboard page that pulls data from at least two different APIs:
- Choose two APIs (e.g., weather + news, GitHub + quotes, Unsplash + random facts)
- Fetch from both APIs simultaneously using
Promise.all() - Display the combined data in a clean layout β cards, grids, or lists
- Add a "Refresh" button that re-fetches the data without reloading the page
- Handle errors independently β if one API fails, the other should still display
Deliverable: A working dashboard HTML file that displays live data from two different APIs, with error handling and a refresh button.
React is a JavaScript library for building user interfaces. Created by Facebook (Meta), it's the most popular front-end framework in the world. It powers Instagram, Airbnb, Netflix, Discord, and thousands of other apps.
Why learn React as a creator? Because it lets you build interactive, dynamic applications β not just static pages. Dashboards, storefronts, portfolio sites that update in real time, content management tools. Things that feel like apps, not websites.
The Core Idea: Components
React breaks your UI into components β reusable, self-contained pieces. A page isn't one giant HTML file; it's a tree of components:
<App>
<Header />
<ProductGrid>
<ProductCard />
<ProductCard />
<ProductCard />
</ProductGrid>
<Footer />
</App>
Each component manages its own logic and rendering. You build small components and compose them into bigger ones. This makes code reusable and maintainable.
JSX: HTML in Your JavaScript
React uses JSX β a syntax extension that lets you write HTML-like code inside JavaScript:
function Welcome() {
const name = "Creator";
return (
<div className="welcome">
<h1>Hello, {name}!</h1>
<p>Welcome to your dashboard.</p>
</div>
);
}
The curly braces {} let you embed JavaScript expressions inside JSX. Notice className instead of class β that's a JSX thing (because class is a reserved word in JavaScript).
Props: Passing Data Down
Props (properties) are how you pass data from a parent component to a child component:
function ProductCard({ title, price, image }) {
return (
<div className="card">
<img src={image} alt={title} />
<h3>{title}</h3>
<p>${price}</p>
</div>
);
}
// Usage:
<ProductCard title="Audio Pack" price={14.99} image="/pack.jpg" />
Props flow one direction: parent to child. This makes data flow predictable and easy to debug.
State: Data That Changes
State is data that can change over time β a counter, form input, whether a menu is open, a list of items from an API. React's useState hook manages state:
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Add One
</button>
</div>
);
}
When state changes, React automatically re-renders the component. You never manually update the DOM. You change the data, and React updates the UI to match. This is declarative programming β you describe what the UI should look like for a given state, and React figures out how to make it happen.
Setting Up a React Project
The fastest way to start a React project in 2026:
npx create-vite my-app --template react
cd my-app
npm install
npm run dev
This gives you a development server with hot reloading β change your code and the browser updates instantly. Vite is the modern build tool of choice (faster than the older Create React App).
π‘ Key Takeaway
React's mental model is simple: components + props + state = UI. Everything else is just building on that foundation. If you understand these three concepts, you understand React.
π¨ Exercise 4.3: Build a Simple React App
Create a React application from scratch:
- Initialize a new React project with Vite
- Build at least 3 components: a Header, a main content area, and a Card component
- Use props to pass data into your Card component (title, description, image or icon)
- Add state β a toggle button that shows/hides content, a counter, or a simple search filter
- Style it with CSS (a separate CSS file or inline styles). Make it look intentional, not default.
- Render a list of at least 5 items using
.map()
Deliverable: A GitHub repository (or zip file) with your React project. Include a screenshot of the running app.
This is where everything comes together. You're going to build a real, functional web application β not a toy project, not a tutorial clone. A tool that serves your creator business: a dynamic portfolio site, a storefront for your digital products, or a content dashboard that aggregates your metrics.
Choosing Your Project
Pick the one that's most useful to you right now:
- Dynamic Portfolio β A React-powered portfolio that pulls your content from an API (YouTube videos, GitHub repos, blog posts). Updates automatically when you publish new work. Includes an about section, project gallery, and contact form.
- Digital Storefront β A product catalog for your digital goods (audio packs, scripts, templates). Product cards with images, descriptions, and prices. Filter/sort by category. Shopping cart functionality. Connects to a payment system concept.
- Creator Dashboard β A personal dashboard that displays your key metrics. Fetch data from APIs (social stats, analytics, revenue). Display charts or data cards. Refresh on demand. Useful as a personal tool you'll actually use.
Project Architecture
Whatever you build, structure it properly:
src/
βββ components/
β βββ Header.jsx
β βββ Footer.jsx
β βββ Card.jsx
β βββ ...
βββ pages/
β βββ Home.jsx
β βββ About.jsx
β βββ Projects.jsx
βββ hooks/
β βββ useFetch.js β custom hook for API calls
βββ data/
β βββ projects.json β fallback data if API is down
βββ App.jsx
βββ App.css
βββ main.jsx
Building a Custom Hook
Hooks are reusable pieces of stateful logic. A custom useFetch hook saves you from writing the same fetch logic in every component:
import { useState, useEffect } from 'react';
function useFetch(url) {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
fetch(url)
.then(res => res.json())
.then(setData)
.catch(setError)
.finally(() => setLoading(false));
}, [url]);
return { data, loading, error };
}
Now any component can fetch data in one line: const { data, loading, error } = useFetch(apiUrl);
Responsive Design in React
Your project needs to work on mobile. Use CSS media queries (you already know these from earlier courses) or a utility framework like Tailwind CSS. Test on multiple screen sizes. Creator audiences browse on phones β if your portfolio or storefront breaks on mobile, you lose them.
Deployment
Your project should be live on the internet. Free hosting options:
- Vercel β Best for React apps. Connect your GitHub repo and it deploys automatically on every push. Free tier is generous.
- Netlify β Similar to Vercel. Drag-and-drop deployment or GitHub integration.
- GitHub Pages β Free static hosting. Works for React apps with a build step.
A project that isn't deployed doesn't exist. Get it online.
π¨ Exercise 4.4: Dynamic Creator Tool (Course Deliverable)
Build and deploy your dynamic creator tool:
- Choose your project type: portfolio, storefront, or dashboard
- Build it in React with at least 5 components
- Fetch real data from at least one API
- Include loading states, error handling, and responsive design
- Deploy to Vercel, Netlify, or GitHub Pages
- Include a README.md explaining what the project does and how to run it locally
Deliverable: A deployed URL for your live application + a GitHub repository with clean, commented code. This project becomes a centerpiece of your developer portfolio.
π‘ Course Complete
You've leveled up from writing static pages to building dynamic, data-driven web applications with React. You can fetch API data, manage state, compose components, and deploy real applications. Next up: MULT-205 Content Management Systems, where you'll learn to build and customize sites with WordPress β a different approach to web development that powers 40% of the internet.