use class will mack an exception
EzrealPrince opened this issue · 0 comments
EzrealPrince commented
node version: v10.14.0
express
my router.js:
const a = require('../api/test.js');
router.get('/', (req, res, next) => new a(req, res, next).main() );
my test.js
module.change_code = 1;
class test {
constructor(req, res, next) {
this.req = req;
this.res = res;
// super(req, res, next);
}
main() {
const b = {
a: 1,
b: 2
}
this.res.render('index', { title: 'Express11' , ...b})
}
}
module.exports = test;