This article will guide you on how to write a basic web server using Nodejs and Expressjs

To continue with this article you must have had Nodejs installed on your workstation, if not you can refer to my last article on getting started with Nodejs.

We will also need Postman;

Postman is a scalable API testing tool. It started in 2012 as a side project by Abhinav Asthana to simplify API workflow in testing and development. API stands for Application Programming Interface which allows software applications to communicate with other softwares via API calls.

To get get started visit the Postman official website and download the right version according to your OS.

After it must have downloaded, check your downloads directory for the executable file and launch it.

Image for post

Image for post

Make a directory anywhere on your filesystem and name it NodeServer or any name of your choice, then open your favourite code editor and open the newly created folder.

Open your command line interface and navigate to the newly created folder.

Then type npm init -y and hit enter. This will create a package.json file and a node_modules folder in your project root directory.

In the terminal enter** npm install express **and hit enter.

This will add the **express **npmpackageto your package.json folder as a dependency like so.

Image for post

Back in your code editor, create a new file named server.js then replicate the code in the picture below.

Image for post

Back to your command line interface type **node server.js **and hit enter, if all is right, this will start the server and log “Server started on port 2000” in the CLI.

Image for post

Back to the postman application, enter the API endpoint as seen in the picture above and hit the send button.

#postman #api #nodejs #express #node-js-tutorial

Back-End With Javascript: Creating a Basic Web Server
1.15 GEEK