0
我想重定向到一個404頁面,如果沒有找到一個id我想重定向到一個404頁面,如果沒有找到一個id
頁路線/ users.js
exports.find = function(req, res) {
var id =(req.params.id);
db.getFindById(id,function(err, results){
if (err) return res.send(500, "DB QUERY ERROR");
res.render('usr/details', { finds: results });
});
}
頁index.js
app.configure(function(){
app.set('views', __dirname +'/views');
app.set('view engine','jade');
app.use(express.bodyParser({KeepExtensions: true, uploadDir: path.join(__dirname, '/public/img/user-avatar')}));
app.use(express.methodOverride());
app.use(checkDatabase, function(req, res) {res.send(404, "Could not find ")});
app.use(passport.initialize());
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/list-users/finds/:id',checkDatabase);
的ReferenceError:未定義checkDatabase – rokirakan78
的當然你必須用上面的函數名來替換它。我不知道你需要導出模塊的變量名稱是什麼。 – MildlySerious
app.configure(函數(){ \t app.set( '視圖',__dirname + '/視圖'); \t app.set( '視圖引擎', '玉'); \t app.use(表達.bodyParser({KeepExtensions:true,uploadDir:path.join(__ dirname,'/ public/img/user-avatar')})); \t app.use(express.methodOverride()); \t app.use ();); \t app.use(express.static(path.join()); \t app.use(express.static(path.join) (__dirname,'public'))); }); – rokirakan78