1)
If next is called then it function will not return after execution of request.
app.get(/dishes/:dishId, function(req, res, next) {
res.end(‘sending it to server’+ req.params.dishId);
});
2)
Get the request data
req.body.name; req.body.description
3)
res.write();
res.end();
4) Express Routers
var dishRouter = express.Router();dishRouter.use(bodyParser.json());
dishRouter.route(‘/’)
.all(function(req,res,next){
res.writeHead(200, {‘Content-type’:’text/plain’});
next();
})
.get(function(req,res, next) {
res.end(‘retrieving the request’);
});
app.use(‘/dishes’, dishRouter);