Today we’re going to learn about express js.

We can start using checking the official document of express js —

We are going to use express mostly for 3 reasons

  • Easy routing system
  • Can use with many templating system
  • Have a middleware framework

We can start with the routing. Before express we write a long code to create a server, but with express it’s pretty easy. See the old code

Now we are going to write the same old code using express.

First we need to require express then create an app constant using express()

Now we can write app.listen(3000) to listen 3000 port.

We can write the routes now. Like homepage –

Now our code is more readable and easy to add any route

So you like the introduction of express js ?

Leave a Reply

Your email address will not be published. Required fields are marked *