Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between app.use('*') and app.all('*') in Express

Is there a difference between

app.use('*', function (req, res, next) {

});

and...

app.all('*', function (req, res, next) {

});
like image 386
hyubs Avatar asked Oct 20 '22 07:10

hyubs


1 Answers

app.all() references the application router like post or get, while app.use() simply references the applications middleware. app.use() is better for more globally defined statements that you want persistent through your entire application.

like image 114
Sterling Archer Avatar answered Oct 23 '22 03:10

Sterling Archer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!