Posts

Showing posts from July, 2018

Express.js Middleware Tutorial

Developers who are new to Express often get confused with the difference between route handler and middleware. Therefore they also get confused with the difference between  app.use() ,  app.all() ,  app.get() ,  app.post() ,  app.delete()  and  app.put()  methods. In this tutorial I will explain the exact difference between a middleware and route handler. And also how to use the  app.use() ,  app.all() ,  app.get() ,  app.post() ,  app.delete()  and  app.put()  methods correctly. Route Handler app.all() ,  app.get() ,  app.post() ,  app.delete()  and  app.put()  methods are all used to define routes. A route is used to handle a HTTP request. A route is a combination of a path and callback, which is executed when a request’s path is matches. The callback is called as the route handler. The difference between  app.all() ,  app.get() ,  app.post() ,  app.delete() and  app.put()  methods is that they handle different types of HTTP requests. For example:  app.get()  handlers only