-1
在下面的代碼不是在充當預期快遞使用功能
var express = require('express');
var app = express();
app.use(function(req, res, next) {
console.log('first text');
next();
}, function (req, res, next) {
console.log('secondText');
res.end()
}).listen(3000)
app.use([path,] function [, function...])
支架在指定的路徑指定的中間件功能或多個功能。如果未指定路徑,則在快速文檔中默認爲'/'
,但我無法運行第二個功能,不知道爲什麼。當我嘗試localhost:3000
在Firefox我收到Cannot GET /
此代碼工作,但以前它是不工作:
var express = require('express');
var app = express();
app.use(function(req, res, next) {
console.log("one");
next();
})
.use(function(req,res,next){
console.log("second");
res.end()
})
.listen(3000)
不,我忘了在帖子中加點,但是如果我加了點,它仍然不起作用 –
爲什麼會這樣下去呢?在時間有效的答案。 – Randy