Weather Request displays a an hourly forecast in any city or town searched by the user, in metric or imperial units. The app is currently deployed at Vercel. I built the app to learn more about React state management, clean code, testing, UI, deployment, and API calls.
How to use the app:
This project uses:
To install the app, you can clone the github repository to your local machine. Navigate to the folder where you want the project to exist, and then run this command:
git clone https://github.com/sarahcode2112/weather-displayer.git
Then navigate to the project directory and run in the command line:
cd weather-displayer
npm install
To run the app, you can run in the command line:
npm start
Then you can view the app at http://localhost:3000 in a web browser.
To run tests, you can run in the command line:
npm test
The Weather Request app relies on an external weather API to provide forecasts. For free, you can make up to 1000 requests per day. To set up the API, follow these steps:
Sign Up and Get API Key: Visit the Weather API Provider's Website and sign up for an account. Once you're signed up, you'll be able to access your API key.
Configure API Key: After obtaining your API key, create a .env
file in the root directory of your app. Use the provided env.template
file as a starting point. Replace YOUR_API_KEY_HERE
with your actual API key.
API Documentation: Optionally, you can read the API Documentation to understand the available endpoints and how the Weather Request app structures its request.
This section explains how to deploy the Weather Request app on Vercel. Before you begin, make sure you have a Vercel account. If you don't have one, you can sign up at Vercel's website.
To enable automatic deployment with Vercel, I recommend pushing your app to a remote Git repository on GitHub.
Create a new repository on GitHub for your version of the Weather Request app if you haven't already.
On your Vercel account dashboard, Click 'Add New', then 'Project,' then import your existing GitHub repository for your version of Weather Request.
Vercel will automatically detect the GitHub repository. Choose the default settings or customize them as desired.
One important step is to set up the API key using the Vercel dashboard (because Vercel will not read the API key in your .env file, which is gitignored). Go to your app's settings on the Vercel website and navigate to the "Environment Variables" section. Add your API key there.
Once the deployment process is complete, Vercel will provide you with a URL where your app is live, where you can visit the site.Vercel will automatically handle continuous deployment. Whenever you push changes to your linked GitHub repository, Vercel will build and deploy the updated app.
To help with debugging, you can view the full API response on the web page by adding this div to a frontend component, such as WeatherDisplay.tsx:
<div>
{/* Full response: {JSON.stringify(response)} */}
{/* display response data as string */}
</div>
For questions or feedback, you can reach out to [email protected] or visit my GitHub profile.