Answer the question
In order to leave comments, you need to log in
How is express.Router() different from express().get in express?
Answer the question
In order to leave comments, you need to log in
Through Router, you can set routes to a separate namespace so as not to repeat
// 1 вариант
app.get('/api/users', ...)
app.post('/api/users', ...)
app.put('/api/users', ...)
let router = new Router();
// 2 вариант
router.get('/users', ...)
router.post('/users', ...)
router.put('/users', ...)
app.use('/api', router);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question