Em meus roters crio:
var express = require('express');
var router = express.Router();
var service = require('./../services/users');
router.get('/login', service.login);
router.get('/register', service.register);
router.get('/edit/:id', service.edit);
module.exports = router;
Onde tem o service:
exports.login = function(req, res) {
res.render('login');
};
exports.register = function(req, res) {
res.render('register');
};
mas quando rodo o npm start
dá a mensagem de erro:
\node_modules\express\lib\router\route.js:202
throw new Error(msg);
^
Error: Route.get() requires a callback function but got a [object Undefined]
at Route.(anonymous function) [as get] (C:\mean\parking\node_modules\express\lib\router\route.js:202:15)
at Function.proto.(anonymous function) [as get] (C:\mean\parking\node_modules\express\lib\router\index.js:510:19)
at Object.<anonymous> (C:\mean\parking\routes\users.js:7:8)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\mean\parking\app.js:9:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ramos\AppData\Roaming\npm-cache\_logs\2018-11-03T16_02_53_765Z-debug.log
O que posso estar fazendo de errado?