Weather Dashboard
Intermediate Project โ Master Fetch API, Async/Await, Error Handling & Dynamic UI
๐ง Project Overview
A Weather Dashboard is one of the best intermediate JavaScript projects because it forces you to work with real APIs, handle async operations, manage loading states, and design error-proof UI.
These skills form the core of modern frontend development, especially for apps that depend on live data:
- โข Social media feeds
- โข Stock/crypto price apps
- โข Fitness trackers
- โข News dashboards
- โข Weather apps (like the one you're building)
The project uses OpenWeatherMap, the same API powering millions of weather apps, from basic dashboards to advanced meteorology tools.
By finishing this project, you master:
- โ Calling real APIs
- โ Using JSON data
- โ Async/await clean syntax
- โ Handling errors properly
- โ Rendering data dynamically
- โ Building responsive UI
- โ Managing user input
- โ Working with icons, images & conditions
๐ฏ Goal
Build a Weather Dashboard that lets the user:
- โ Search for a city
- โ Display real-time weather (temperature, humidity, wind speed)
- โ Show weather condition icons
- โ Show weather descriptions ("Overcast", "Cloudy", "Light Rain", etc.)
- โ Manage loading states
- โ Handle bad input (empty text, invalid city names)
- โ Display helpful error messages
- โ Use async/await to keep code clean
๐งฉ Core Concepts You Will Learn
This project teaches all the must-know intermediate JavaScript concepts:
โข Fetch API
Sending GET requests to remote servers.
โข async/await
Clean, readable asynchronous code.
โข JSON Parsing
Extracting data from API responses.
โข Error Handling
Using try catch around fetch operations.
โข Conditional Rendering
Weather icons, temperature displays, backgrounds.
โข DOM Manipulation
Updating UI with real live API data.
โข State Management
Loading states, error states, previous searches.
โ ๏ธ API Key Required (FREE)
To fetch real weather data, you need a free API key.
How to get it:
- 1. Go to openweathermap.org/api
- 2. Create a free account
- 3. Go to "API Keys"
- 4. Copy your unique key
- 5. Replace
YOUR_API_KEYin your script
๐ก Keys can take 5โ10 minutes to activate.
๐ป Starter Code (Simplified, Clean, Expandable)
This is your fully working Weather Dashboard starter. Add your API key to make live data work. Test it below and see how all the pieces work together!
Weather Dashboard Starter Code
Fetch real weather data from OpenWeatherMap API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg,#4facfe 0%,#00f2fe 100%);
min-height: 100vh;
padding: 20px;
color: #fff;
}
.container {
max-width: 500px;
margin: auto;
background: rgba(255,255,255,0.2);
padding: 25px;
border-radius: 12px;
backdrop-
...๐ Deep Enhancement Ideas (Turn This Into a Full App)
These features take your dashboard from "beginner project" to portfolio ready:
๐ฎ 1. 5-Day Forecast
Use: https://api.openweathermap.org/data/2.5/forecast
You can:
- โข Show one card per day
- โข Add small icons
- โข Display highs/lows
This teaches: Array filtering, Grouping forecast points, Card-based UI
๐ 2. Geolocation Detection
Auto-detect the user's city:
navigator.geolocation.getCurrentPosition(success, error);
Then call: weather?lat=...&lon=...
This makes your app feel premium.
๐ 3. Hourly Temperature Graph
Use a simple canvas chart: Chart.js or your own SVG graph
Shows mastery of: Data visualization, Parsing JSON arrays, Rendering dynamic graphics
๐พ 4. Recent Searches
Store them in localStorage:
localStorage.setItem("recent", JSON.stringify(list));Display as clickable buttons.
๐ 5. Unit Toggle
Switch between ยฐC and ยฐF
Formula: F = C ร 1.8 + 32
Add a UI toggle button.
๐จ 6. Dynamic Backgrounds
Change background depending on data:
- โข Rain โ blue
- โข Clear โ yellow/gradient
- โข Snow โ white/gray
- โข Night โ dark blue
This creates an immersive feel.
๐ Perfect Completion Checklist
Your Weather Dashboard should:
- โSearch city
- โDisplay full weather details
- โShow icons
- โHandle loading
- โHandle errors
- โUpdate UI dynamically
- โUse async/await
- โParse JSON
- โHave a clean layout
- โNo console errors
- โWorks on mobile
- โUses your API key safely