I created a NodeJS application with port 7777.
server.js
'use strict';
var express = require('express'),
router = require('./router');
var app = express();
var port = 7777;
app.use(router());
app.listen(port);
console.log('Doctor appointment at ' + port);
I am calling router from server and executng application as node server.js
router.js
'use strict';
var express = require('express');
var doctorAppointment = require('./controllers/doctorAppointment');
module.exports = function() {
var options = {
caseSensitive: true
};
console.log("Router");
// Instantiate an isolated express Router instance
var router = express.Router(options);
router.post('/appointment', doctorAppointment.takeAppoiment);
return router;
}
I am calling controller method from router. Controller follows:
doctorAppointment.js
'use strict';
exports.takeAppoiment = function(req, res, next) {
console.log("Inside appointment");
}
After execution, controller method is not calling
system@DT-LNX-315:~/Desktop/nodeJS/doctor-appointment$ node server.js
Router
Doctor appointment at 7777
And end point defined in http://localhost:7777/
coming as Cannot GET / in browser
And for http://localhost:7777/appointment
showing as Cannot GET /appointment. How to execute controller method?