normalizr没有返回与实体匹配的结果字段?

时间:2018-12-16 14:41:53

标签: normalizr

我有这样的回复:

{
  count:2,
  todos: [ { complete: false,
        id: '5c15338940b1893ff8e53c63',
        text: 'add todo test',
        userId: '5c0c0965f9c34b071c11a3f1',
       createdAt: '2018-12-15T17:02:01.512Z',
        updatedAt: '2018-12-15T17:02:01.512Z',},
      { complete: false,
        id: '5c1532bdccba3c2128358764',
        text: 'add todo test',
        userId: '5c0c0965f9c34b071c11a3f1',
        createdAt: '2018-12-15T16:58:37.134Z',
        updatedAt: '2018-12-15T16:58:37.134Z', },

我现在具有以下架构:

const todo = new schema.Entity('todos');;
    const result = normalize(response, {
      todos: [todo],
    })

我期望这样的结果:

{
  entities: {
    todos: {
    '5c1532bdccba3c2128358764': { 
        complete: false,
        id: '5c1532bdccba3c2128358764',
        text: 'add todo test',
        userId: '5c0c0965f9c34b071c11a3f1',
        createdAt: '2018-12-15T16:58:37.134Z',
        updatedAt: '2018-12-15T16:58:37.134Z',
   } }
  },
  result: { todos: [ '5c1532bdccba3c2128358764' ] }
}

但是我在结果上得到的是一个ID数组,而我没有待办事项作为具有ID数组的字段:

result: ['5c1532bdccba3c2128358764']

帮助?

0 个答案:

没有答案