Reputation: 21
I am a beginner and struggle to read documentation although, practically, I can understand what the documentation says by looking at the code implementation.
For example, app.use([path,] callback [, callback...])
I understand how to use the method but I still have no clear understanding of the notation used in the documentation. For instance, questions that I have in mind:
I hope somebody can help me, thanks!
Upvotes: 2
Views: 79
Reputation: 57234
For general context, use
adds a middleware function(s) to the Express request handler.
path
parameter is in a square bracket because it's optional. If you omit it, then the middleware callback is applied to all incoming requests. If you provide a path string, then only requests matching the path will be passed to the middleware callback.path
, there is a comma delimiting it from the required callback
second parameter. Because the second parameter callback
isn't in brackets, it's required. The parameter list would look weird if this comma wasn't there after path
, because it wouldn't match the JS syntax you'd use to provide multiple parameters to a function.callback...
means you can provide multiple callbacks.Upvotes: 1