Chapter 15.3โ˜• 25 min read

Weather Dashboard with APIs

Build a real-time weather dashboard using OpenWeatherMap API, RxJS debounceTime/switchMap, signals, interceptors, and error handling.

01What We'll Build

What We'll Build

  • Real-time weather dashboard for any city
  • City search with debounce (500ms)
  • Current weather: temperature, humidity, wind
  • 5-day forecast with min/max temps
  • Loading spinner, error messages, retry button

"Hyderabad ka mausam โ€” abhi kitni garmi hai, pata karo"

Uses: HTTP (Ch 7), RxJS operators (Ch 9.4), Signals (Ch 10), Interceptors (Ch 7.3), Pipes (Ch 4.3).

02API Setup

API Setup

OpenWeatherMap: free tier, 1000 calls/day. Sign up, get API key.

// Endpoint
api.openweathermap.org/data/2.5/weather?q=Hyderabad&appid=KEY&units=metric

Create interceptor to add API key automatically (Ch 7.3).

"API key = restaurant ka membership card โ€” bina ke andar nahi jaoge"

03Current Weather

Current Weather Feature

  • City search input with debounceTime(500) (Ch 9.4)
  • switchMap to cancel previous search
  • toSignal() to convert Observable to signal (Ch 10.5)
  • Display: temperature, humidity, wind speed, icon

"Type karo city name โ†’ 500ms ruko โ†’ API call โ†’ dikhao"

045-Day Forecast

5-Day Forecast Feature

  • Separate API call for forecast
  • Group by day, show min/max temp
  • @for loop with date pipe formatting (Ch 4.3)

"5 din ka forecast โ€” plan your week"

05Error Handling & Loading

Error Handling & Loading States

  • Loading spinner while API calls
  • City not found error โ†’ friendly message
  • Network error โ†’ "Check your internet"
  • Retry button on error

"Error handling = umbrella โ€” barish aaye toh ready ho"

Project Summary

  • debounceTime + switchMap for search (prevents excessive API calls)
  • toSignal() converts Observable to signal
  • Interceptor adds API key to all requests
  • Loading, success, and error states with signals
  • 5-day forecast grouped by day
Course Search
Search across all chapters & stages
๐Ÿ“–

Search the course

Type any topic โ€” branching, stash, rebase, hooks โ€” and jump straight to that chapter.

merge branchesgit stashundo commitrebase