我试图通过从mongodb数据库获取页面,使用express动态创建nodejs中的路由。
我在routes.js中的代码类似于:
module.exports = function(app, passport) {
Page.find(function(err,leroutedata){
leroutedata.forEach(function(page) {
var path = page.path;
app.get(path,function(req, res){
res.render('layout.ejs', { data : page });
});
});
});
};但我知道这个错误:
(...)/node_modules/path-to-regexp/index.js:34
.concat(strict ? '' : '/?')
^
TypeError: Cannot read property 'concat' of undefined有什么会导致的吗?
发布于 2015-12-18 10:52:23
您的page.path可能不是字符串或Regex。
https://stackoverflow.com/questions/34353877
复制相似问题