Answer the question
In order to leave comments, you need to log in
How to put all routing into a separate file (module) on Node?
Good evening!
I wondered how to transfer the entire routing to a separate file so that my eyes would not be an eyesore.
For example, there are several.
app.get('/', function(req, res) {
res.render('index');
});
Answer the question
In order to leave comments, you need to log in
1. in app.js
2. in your project, create a routes directory and index.js there, in which you write all the routes
module.exports = function (app) {
app.get('/', function(req, res) {
res.render('index');
});
app.get('/user', function(req, res) {
res.render('user');
});
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question