I\'m starting coding using nodejs with express. So i did this in my file test.js which is into my folder routes :
const express = require(\'express\');
const ro
The problems seems to be how you are mounting the router. Looking the the router middleware API it seems you should be doing it like this.
test.js
const express = require('express');
const router = new express.Router();
router.get('/test', (req, res, next) => {
res.send("I'm a test");
next();
});
module.exports = router;
server.js
const express = require('express');
const app = express();
const test = require('./test');
app.use('/', test);
app.listen(3000);