A responsive weather application that displays current weather and 5-day forecast using OpenWeatherMap API.
A clean and responsive weather application that provides current weather conditions and a 5-day forecast for any city worldwide.
This weather app helps users:
class WeatherApp {
constructor() {
this.apiKey = "your-api-key";
this.baseUrl = "https://api.openweathermap.org/data/2.5";
this.init();
}
async getCurrentWeather(city) {
try {
const response = await fetch(
`${this.baseUrl}/weather?q=${city}&appid=${this.apiKey}&units=metric`
);
const data = await response.json();
this.displayCurrentWeather(data);
} catch (error) {
this.showError("Failed to fetch weather data");
}
}
displayCurrentWeather(data) {
document.getElementById("temperature").textContent = `${Math.round(
data.main.temp
)}°C`;
document.getElementById("description").textContent =
data.weather[0].description;
document.getElementById("humidity").textContent = `${data.main.humidity}%`;
}
}
This project showcases practical skills in API integration, responsive design, and creating user-friendly web applications.
I'm always excited to work on new challenges and bring innovative ideas to life.