GetWeather is a website that shows the weather for certain cities. It allows the user to search for the weather in certain cities by querying the city name. The user has to enter the name of the city and hit go to get weather data of the particular city.
The website uses gets weather data from the openweathermap.org API. After the user hits the go button, it fetches the weather data of the city from openweathermap.org.
Tech Stack: NodeJS, Express
API: https://openweathermap.org/current#list
The user has to type in the city name and hit the go button to get the weather data of the city.
While learning backend web development I wanted to create a real world project using the knowledge I acquired about backend web development and APIs which motivated me to work on this project.
For development, you would need Node.js installed in your enviornment.
-
Just go on official Node.js website and download the installer. Also, be sure to have
git
available in your PATH,npm
might need it (You can find git here). -
You can install nodejs and npm easily with apt install, just run the following commands.
$ sudo apt install nodejs $ sudo apt install npm
-
You can find more information about the installation on the official Node.js website and the official NPM website.
If the installation was successful, you should be able to run the following command.
$ node --version
v8.11.3
$ npm --version
6.1.0
If you need to update npm
, you can make it using npm
! Cool right? After running the following command, just open again the command line and be happy.
$ npm install npm -g
After installing node:
To get the Node server running locally:
-
Clone this repo
-
On the command line, navigate to the root directory of your package. cd /path/to/package.
-
Initialise the npm by running the following command
npm init
-
After initialising npm, you would need to install express using npm. To install express using npm use the following command
npm install express
-
After installing express, you can start the express server using the following command
node app.js
-
After starting the server, you should get a message - "Server is running on port 3000" and your app should be now running at localhost:3000
- expressjs: The server for handling and routing HTTP requests
- app.js - The entry point to our application. This file defines our express server.
- Learnt about Node.js
- How to install Node.js on Mac
- Using the native node modules
- npm package manager and installing external node modules
- express and creating first server with express
- API - Application Programming Interface
- API endpoints, paths and parameters
- API authentication
- JSON
- Making GET requests with Node HTTPS modules
- Parsing JSON
- Using express to render a website with live API data
- Using body parser to parse POST requests with the server
Santosh Shivam - Twitter | LinkedIn
MIT © Santosh Shivam