I realize this is probably a pretty noob question, and that there's a ton of articles about this very thing, but I'm having a super hard time finding an explanation that's clear to me, and that makes sense. I also didn't find this question in stackoverflow.
My question is simply: In express, what's the difference between app.set, and app.use?
My question is simply: In express, what's the difference between app.set, and app.use?
app.set(name, data)
stores a named property on the app
object that can be retrieved later with app.get(name)
. Some property names for app.set()
have predetermined effects that are described in the Express doc and work like configuration options.
app.use()
registers a middleware callback that will be part of the request handler chain for incoming http requests. Depending upon the arguments, the middleware will either be called for all incoming requests or only for certain requests.
The two are complete different operations that are not directly comparable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With