Wednesday, 12 April 2017

In express, why app.use function can use route argument?

In express framework 'app.use('/users', users);' defined in app.js and then use 'get('/', function(req, res, next){})' in route, why it can work when I search localhost:3000/users ?

Because I see native code , the path is always undefined, if use 'use' middleware, this is layer.js https://github.com/expressjs/express/blob/master/lib/router/layer.js#L44 enter image description here and also I debug the path is also undefined



via ZHONGJIAFENG

No comments:

Post a Comment