[英]Nodejs / Express / second router doesn't work
this code works for my home page此代码适用于我的主页
router.get('/', async function(req, res, next){
await default_context('accueil', "Accueil", req.session).then(async (context)=>{
res.render('base/html', context)
})
})
When I want to add a second Router :当我想添加第二个路由器时:
var another_router = express.Router()
another_router.get('/database', (req, res) =>{
var posts = []
console.log("another router")
res.render('base/html', posts)
})
it produces a 404 error它会产生 404 错误
EDIT it produces an error when trying to access with /database in the URL编辑它在尝试使用 URL 中的 /database 访问时会产生错误
Why do you want another router?为什么要另一个路由器?
If all you want is another route then just do router.get('/database', ...)
如果您想要的只是另一条路线,那么只需执行router.get('/database', ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.