Keystone JS 视图上的事件不起作用

Event on Keystone JS view not working

我正在用 KeystoneJS 做一个电子商务网站(学习目的)。在我显示所有产品的视图中,我想添加一个过滤器以按价格对项目进行排序,另一个过滤器仅显示一个品牌的产品。需要两份表格,但我不能只提交一份

我的products.pug看起来像这样

.container
  form(method='post')
    input(type='hidden', name='action', value='products')
    button(type='submit').btn.btn-primary Send

我在 routes/views/ 中的 products.js 看起来像这样

[...]
// Print a word when submit the form
view.on('post', { action: 'products' }, function(next) {
  console.log('POST')
  next()
})
// Get all products from db
view.on('init'...)
// Render
view.render('products')

所以基本上我想做的是在我点击视图中的按钮时打印 POST。相反,我收到了一个 404 错误页面。如果你们能帮助我,我将不胜感激

知道了!在 /routes/index.js 中我替换了

app.get('/products', route.views.products);

app.all('/products', route.views.products);

我觉得很傻但是很开心。