24

Oct 2019

Module CRUD - Route

Route

Route path refers to how the application responds to a data request, and how the application performs a data request so that a special path occurs. The route path is divided into 5 methods (GET, POST, PUT, DELETE, LISTEN). Following are examples of the application of these methods:


Route Method

Route Method

Description

app.get()

Example: 

app.get('/members', function(req, res) {
require('../controllers/membersController').index(req,res);
});

 

app.post()

Example: 

app.post('/members', function(req, res) {
res.send(require('../controllers/membersController').create(req,res));
});

 

app.put()

Example: 

app.put('/members/:id', function(req, res) {
res.send(require('../controllers/membersController').update(req,res));
});

 

app.delete()

Example: 

app.delete('/members/:id', function(req, res) {
res.send(require('../controllers/membersController').erase(req,res));
});

 

app.listen()

Example: 

app.listen(port);