express
express copied to clipboard
is not a function
const express = require('express');
const testController = require('./test.controller')
const router = express.Router();
router.get('/test', testController.getName);
module.exports = router;
const testController = {
getName(req, res,next) {
console.log(this.getAge())
res.send("kjkj")
},
getAge: function (req, res) {
return "age 10";
},
}
module.exports = testController
TypeError: this.getAge is not a function at getName (D:\projects\taski\curry\curry_cuts_server\routes\test\test.controller.js:3:26) at Layer.handle [as handle_request] (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\layer.js:95:5) at next (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\layer.js:95:5) at D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:281:22 at Function.process_params (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:335:12) at next (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:275:10) at Function.handle (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:174:3) at router (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:47:12) at Layer.handle [as handle_request] (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:317:13) at D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:284:7 at Function.process_params (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:335:12) at next (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:275:10) at D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:635:15 at next (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:260:14) at Function.handle (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:174:3) at router (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:47:12) at Layer.handle [as handle_request] (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:317:13) at D:\projects\taski\curry\curry_cuts_server\node_modules\express\lib\router\index.js:284:7