Skip to content

Abhinavpatra/WeatherApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather for You

This React application allows users to check the current weather by entering either a city name or a pincode. It utilizes the OpenWeatherMap API to fetch weather data based on the provided city name. If a pincode is entered, it first fetches the corresponding city name using the Google Maps Geocoding API and then retrieves weather information.

Installation

  1. Clone the repository: git clone <repository_url>

  2. Navigate to the project directory: cd <project_directory>

  3. Install dependencies: npm install

  4. Set up environment variables:

  • Get an API key from OpenWeatherMap and replace 'YOUR_OPENWEATHERMAP_API_KEY' with your API key in the getWeather() function.
  • Get an API key from Google Maps and replace 'YOUR_GOOGLE_API_KEY' with your API key in the getWeatherByPincode() function.
  1. Run the application: npm start

Usage

  1. Enter a city name in the input field and click "Get Weather" to fetch the weather details for the specified city.
  2. Alternatively, enter a pincode in the input field and click "Get Weather" to retrieve the weather information based on the corresponding city.

Technologies Used

  • React.js
  • useState Hook for managing component state
  • Fetch API for making HTTP requests
  • OpenWeatherMap API for weather data
  • Google Maps Geocoding API for converting pincode to city name

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -am 'Add your feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Create a new Pull Request.

License

This project is licensed under the terms of the MIT license. Replace 'YOUR_OPENWEATHERMAP_API_KEY' and 'YOUR_GOOGLE_API_KEY' with your respective API keys

Link to get the weather and data using city name

https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=1b4de0d3fd5f51d4669f87a945488671

the site is active and on, i only need to get access to a googlemaps api key to get the city name from the pincode

But other functionalities still work without it.

only thing left is to get an API key

http://localhost:5173/