4
I am using version v0.10.37 of Node and 4.8 of Express. I am trying to set the route to index. And the following errors appear
Error: Route.get() requires callback functions but got a [Object Undefined]
Or:
Error: Cannot find module './app/Routes/home'
app/controller/home.js
module.exports = function() {
var controller = {};
index: function(req, res) {
res.render('index', {nome: 'Express'});
};
return controller;
};
app/Routes/home.js
var controller = require('./app/controllers/home');
module.exports = function(app) {
app.get('/index', controller.index);
app.get('/', controller.index, function() {});
};
config/express.js
var express = require('express');
var home = require('./app/routes/home');
module.exports = function() {
var app = express();
app.set('port', 3000);
app.set('view engine', 'ejs');
app.set('views', './app/views');
//middleware
home(app);
return app;
};
Alane, did you solve this problem? The answer helped?
– Sergio