This tuturial will show you how to create simple weather app using node.js and OpenWeatherMap API.
Step 1- Create an account on the site OpenWeatherMap.
To get start we need to acess the OpenWeatherMap website https://home.openweathermap.org/users/sign_up and register:
Then we select API Keys and it will create a key, to do this we have to insert in the name field a name that will be associated with the key that is generated.
Once created the acess Key to the API we will develop the app that wil call the API from site OpenWeatherMap.
Step2- Developing the app
The first thing to do is to create a directory with the name nodejs-weather and then we open Node.js command prompt and type the following comand (after we change the directory):
Fill the fiels with the information you want and press enter.
The output will be similar to the image below:
Then wwe type the following command to add the packages:
npm install request — save
The we create aa Notepad++ file with the name Index.js and type the following code:
In the line 3 we change the apiKey by the one that was generated previously on the website OpenWeatherMap.
Then on the Node.js command prompt type the following command:
The output will look like yhis: