What is the difference between app.use and app.get?

Express basics and middleware · Freshers and experienced

Model answer

app.get handles only GET requests for a path. app.use mounts middleware or routers for all methods, and matches any path that starts with the given prefix. Use app.use for things that apply broadly, like json parsing and routers.

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