A real-time weather dashboard built with HTML5, CSS3, and vanilla JavaScript (ES6+). Search any city to view current temperature, humidity, wind speed, and conditions powered by the OpenWeatherMap Current Weather API.
- Async API integration —
fetchwithasync/await, modular API and DOM layers - Error handling — network failures, invalid cities (404), rate limits (429), and invalid API keys surfaced in the UI
- Dynamic rendering — city, country, temperature (°C), humidity, wind, description, and weather icons
- Interactive search — submit button or Enter key, with loading spinner during requests
- Responsive design — optimized for desktop, tablet, and mobile
weatherdash/
├── index.html # Semantic markup & accessibility
├── styles.css # Custom responsive UI (no CSS framework)
├── app.js # Config, state, API service, DOM, events
└── server.js # Optional local dev server
- Create a free account at OpenWeatherMap.
- Generate a key at API keys.
- Open
app.jsand set your key:
const CONFIG = {
API_KEY: "your_openweathermap_api_key_here",
// ...
};Never commit your real API key. Keep the placeholder in the repo and add your key locally only.
Option A — Open in browser
Double-click index.html or open it in Chrome via File → Open.
Option B — Localhost (recommended)
ES modules and API calls work more reliably over HTTP:
node server.jsThen open http://localhost:3000.
| Layer | Responsibility |
|---|---|
| CONFIG | API key, base URL, units (metric / imperial) |
| STATE | Loading flag, last query, weather data, errors |
| API service | fetch, JSON parsing, HTTP error mapping |
| DOM | Render weather card, status messages, loading UI |
| Controller | handleSearch() orchestrates the async flow |
- User submits a city →
handleSearch()sets loading state. fetchWeatherByCity()calls OpenWeatherMap and normalizes the JSON.- On success,
renderWeather()updates the DOM; on failure,renderError()shows a user-friendly message. finallyclears loading state regardless of outcome.
| Setting | Default | Description |
|---|---|---|
API_KEY |
YOUR_API_KEY_HERE |
OpenWeatherMap API key |
UNITS |
metric |
metric = °C, imperial = °F |
DEFAULT_CITY |
London |
City loaded on first visit |
- HTML5, CSS3, Vanilla JavaScript (ES modules)
- OpenWeatherMap API
- DM Sans via Google Fonts
MIT — use freely for learning and personal projects.