Skip to content

Anandhu9255/Weather-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌦️ Dynamic Weather Dashboard

A responsive and interactive weather application that provides real-time updates using the OpenWeatherMap API. This project demonstrates advanced Vanilla JavaScript techniques, specifically focusing on asynchronous data fetching and dynamic UI rendering.


🚀 The Engineering Logic

As a developer, I focused on making this app robust by implementing a structured "Fetch-and-Display" cycle:

1. Asynchronous API Integration

Unlike static apps, this project communicates with a remote server.

  • The Logic: I used async/await to handle the fetch request to the OpenWeatherMap API.
  • Why? This ensures the application remains responsive and doesn't "freeze" while waiting for the weather data to travel across the internet.

2. Smart UI Logic (The Emoji Engine)

Instead of just showing text, the app uses a switch(true) statement to analyze the weatherId returned by the API.

  • The Process: It maps specific ID ranges (e.g., 200s for Thunderstorms, 800 for Clear Skies) to unique emojis.
  • Detail: I used Unicode sequences (like \uFE0F) to ensure consistent emoji rendering across different operating systems.

3. Error Handling & Validation

A key part of software engineering is preparing for things to go wrong.

  • Input Validation: The app checks if the input is empty before making a request to save API bandwidth.
  • Try...Catch Blocks: If a user enters a non-existent city or the network fails, the catch block intercepts the error and triggers a user-friendly error message on the card.

🛠️ Tech Stack

  • HTML5: Semantic structure for forms and weather data containers.
  • CSS3: Features a modern linear-gradient background that adds depth to the weather card.
  • JavaScript (ES6+): Utilizes const/let, arrow functions, template literals, and destructuring for clean, readable code.
  • OpenWeatherMap API: The external data source for global weather information.

📂 Key Features

  • Real-time Conversion: Data is fetched in Kelvin and mathematically converted to Celsius using (temp - 273.15).toFixed(1).
  • Dynamic DOM Injection: Elements like h1 and p are created and appended in real-time based on the search result.
  • Responsive Design: Styled with Flexbox to ensure the weather card remains centered and readable on all screen sizes.

💡 What I Learned

Through this project, I deepened my understanding of the Request-Response cycle, learned how to securely use API Keys, and practiced Object Destructuring to extract specific data points from large JSON objects.

About

A dynamic weather dashboard using the OpenWeatherMap API to fetch real-time meteorological data, featuring custom emoji mapping and async/await error handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors