【发布时间】:2016-12-07 18:03:47
【问题描述】:
我用一个非常简单的(国家)列表创建了一个示例,并根据此处的说明创建了 api 路由:https://gist.github.com/JedWatson/9741171
server.js:
app.get('/api/countries', keystone.middleware.api, routes.api.countries.list);
routes/api/countries.js:
import keystone from 'keystone';
export function list(req, res) {
keystone.List('Country').model.find((err, items) => {
if (err) return res.apiError('database error', err);
res.apiResponse({
countries: items
});
});
}
我收到错误Cannot read property 'find' of undefined,List 对象存在但它没有model 属性。有人知道为什么吗? keystone 管理界面按预期工作,并且数据库中有多个对象。
【问题讨论】:
标签: keystonejs