A simple weather application with ASP.NET Core backend and React + Vite frontend.
Fetches real-time weather data from OpenWeather API and displays current weather conditions for any location.
- Fetch weather data from OpenWeather API
- Display current conditions, temperature, feels like, humidity, wind speed, description
- Search for any city
- Error handling: empty input, location not found, API key issues
WeatherApp/
├── weather-api/ # backend
├── weather-frontend/ # frontend
-
Configure API key in environment variable:
export API_KEY=your_openweather_api_key # Linux/macOS setx API_KEY "your_openweather_api_key" # Windows
-
Build and run:
cd weather-api dotnet restore dotnet build dotnet run
-
API endpoint:
GET http://localhost:5131/api/Weather?location=<city>
-
Example response:
{ "location": "Tokyo", "condition": "Rain", "description": "light rain", "animationCode": "rainy", "temperature": 27, "feelsLike": 31, "humidity": 92, "windSpeed": 2.34, "lastUpdated": "2025-10-11T11:14:42Z" }
-
Install dependencies:
cd WeatherFrontend npm install
-
Run dev server:
npm run dev
-
Open browser at http://localhost:5173 (Vite default)
-
Enter city name and press Enter or click Search to fetch weather.
-
Backend uses
ILogger<WeatherService>
for logging -
React frontend handles errors from backend and displays messages to user
-
API key is not committed; use
.env
or environment variables