mercredi 11 février 2015

What's the replacement for passing an array to the first argument of app.get()?


In the past, you could have done something like this:



app.get(['/', '/dashboard'], (req, res, next) => { ... });


in order to have multiple routes using the same route handler.


Several Stack Overflow answers indicate that this behavior is deprecated and should not be used anymore.


Aside from an ugly regex or a semi-hack like putting the function into a variable and passing it to 2 distinct app.get() calls, is there an elegant alternative to just passing an array as the first argument?





Aucun commentaire:

Enregistrer un commentaire