小编Seb*_*ian的帖子

Keystonejs List对象的未定义'model'属性

我创建了一个包含非常简单的列表(国家/地区)的示例,并根据此处的说明创建了api路由:https://gist.github.com/JedWatson/9741171

server.js:

app.get('/api/countries', keystone.middleware.api, routes.api.countries.list);

路线/ 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
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

我收到错误Cannot read property 'find' of undefined,List对象存在但它没有model属性.有人知道为什么吗?keystone管理UI按预期工作,数据库中有多个对象.

keystonejs

3
推荐指数
1
解决办法
372
查看次数

标签 统计

keystonejs ×1