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.
Command
$ npm run start manchester
Response
@@@@@@@@@@@@@@@@@@@
@ 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
npm
with thenpm init -y
command - Create the file
weather.js
-
Create the file
.env
-
Inside this file, store your API key
KEY = 32476f984jf83jf9fdksu32928475
-
Create a
.gitignore
file, and add the reference.env
-
Create "start" script in your
package.json
that runs node withnode --env-file=.env weather.js
Inside weather.js
- Read the city from the user
Hint: You can use
process.argv
- Use fetch to request the information from your chosen API
Read through the returned data from your API and display;
- The city name
- The current weather
- Anything else you might like to add
Hint: You might also like to consider using the chalk library to make your output fabulous 🤩!
Your program should be also able to;
- Allow the user to switch between metric and imperial measurements