Create simple Restful API with MEAN.

PART 1: A simple HTTP API with NodeJs and low level Http

What exactly is Restful programming?

REST stands for Representational State Transfer, therefore Resful programming is a way of building applications in such away that they can easily exchange and make use of information on the internet.

Restful Web services work in away that they allow client (requesting information) to access and manipulate textual representation of web resources on the Server ( providing information).

Let’s get started

Install NodeJs on your laptop.

In your projects folder create a folder restApi

In the restApi folder create a new file server.js

Inside the server.js file, add this code block.

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Paul Obunga\n');
}).listen(3000);
console.log('Server running at http://localhost:3000/');
// Simple low level API with nodeJs and Http

Now open a terminal/ command prompt in that directory and type

node server.js

It should return Server running at http://localhost:3000/

Visit the link in your browser to see the API response.