What is the purpose of express.Router?

Express basics and middleware · Freshers and experienced

Model answer

A Router is a mini application for grouping related routes, for example all /api/users routes in one file, then mounting it with app.use('/api/users', usersRouter). It keeps route files small and lets you attach middleware to a group.

Learn this topic

Express Middleware Explained: next(), Logging and express.json() in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions