Get the latest weather report - from your terminal!
You will be writing a CLI application which uses an external API to get weather information.
The user will provide a city name when they run the program. Your program must use that city name in its request - and print the results into the terminal.
$ node weather.js manchester@@@@@@@@@@@@@@@@@@@
@ WEATHER PROGRAM @
@@@@@@@@@@@@@@@@@@@
It is now 15.25°C in Manchester
The current weather conditions are: scattered clouds-
There are many weather APIs to choose one. Sign up for a free account from one API on the list below, or find your own;
-
Make note of your API key. You will need this later.
-
Read through the API documentation to understand how to use it
- Initalize
npmwith thenpm init -ycommand - Install the
axioslibrary - we will use this to create our network requests - Install the
dotenvlibrary - we will use it to create our environment variables - Create the file
weather.js
-
Create the file
.env -
Inside this file, store your API key
KEY = 32476f984jf83jf9fdksu32928475 -
Create a
.gitignorefile, and add the reference.env
Inside weather.js;
- Read the city from the user
Hint: You can use
process.argv - Import and use the dotenv library to read the API key from your
process.envenvironment - Import and use the axios to request the information from the API
Read through the returned data from your API and display;
- The city name
- The current temperature
- The current weather conditions
- Anything else you might like to add
Hint: You might also like to consider using the colors.js library to make your output fabulous 🤩!
Your program should be also able to;
- Display a 5-day forecast
- Allow the user to switch between metric and imperial measurements