"next('route')" Doesn't Work With ".use()"
Am I doing something wrong here, or does express just not support next('route') with .use()? var express = require('express') var app = express() app.use([ function (req, res, n
Solution 1:
According to the discussion in node issue #2591: since app.use()
defines middleware, and not a "route", next('route')
is meaningless when used with app.use()
.
Solution 2:
The only difference I can tell between .all and .use is that .use defaults the path to /
.
So this works:
var express = require('express')
var app = express()
app.all('/', [
function (req, res, next) {
returnnext('route')
},
function (req, res, next) {
return res.send('sigma')
},
])
app.all('/', function (req, res, next) {
return res.send('alpha')
})
module.exports = app
Post a Comment for ""next('route')" Doesn't Work With ".use()""