无法将Admin与休息api集成在一起

时间:2018-04-23 10:37:26

标签: reactjs admin-on-rest

我在快递中创建了一个返回客户的休息api。我正在尝试使用休息时管理员在管理面板上显示它们。

我无法显示所有客户,但只显示最后一位客户。我不确定是什么问题。

以下是我的应用代码。

import React, { Component } from 'react';
import { jsonServerRestClient, Admin, Resource } from 'admin-on-rest';


import  {UserList}  from './users';


class App extends Component {

  render() {
    console.log({UserList});
    return (
      <Admin restClient={jsonServerRestClient('http://localhost:8080/api')}>
        <Resource name="customer" list={UserList} /> 
      </Admin>
    );
  }
}

export default App;[enter image description here][1]
下面的

是users.js

import React from 'react';
import { List, Datagrid, EmailField, TextField } from 'admin-on-rest';

export const UserList = (props) => (
    <List title="All users" {...props}>      
        <Datagrid>            
            <TextField source="name" />           
            <EmailField source="emailId" />
        </Datagrid>
    </List>
);

但是,无论何时我整合列表,都会显示仅限最后一个客户的详细信息。控制台中还有一个警告

警告:数组或迭代器中的每个子节点都应该有一个唯一的“键”支柱。

Check the render method of `DatagridBody`. 
    in TableRow (created by DatagridBody)
    in DatagridBody (created by shouldUpdate(DatagridBody))
    in shouldUpdate(DatagridBody) (created by Datagrid)
    in table (created by Table)
    in div (created by Table)
    in div (created by Table)
    in Table (created by Datagrid)
    in Datagrid (created by MuiComponent)
    in MuiComponent (at users.js:6)
    in div (created by List)
    in div (created by Card)
    in div (created by Paper)
    in Paper (created by Card)
    in Card (created by List)
    in div (created by List)
    in List (created by WithPermissionsFilteredChildren)
    in WithPermissionsFilteredChildren (created by getContext(WithPermissionsFilteredChildren))
    in getContext(WithPermissionsFilteredChildren) (created by TranslatedComponent(getContext(WithPermissionsFilteredChildren)))
    in TranslatedComponent(getContext(WithPermissionsFilteredChildren)) (created by Connect(TranslatedComponent(getContext(WithPermissionsFilteredChildren))))
    in Connect(TranslatedComponent(getContext(WithPermissionsFilteredChildren))) (at users.js:5)

请帮助我..我尝试了所有的选择......但运气好。 我附上了应用程序的屏幕截图 enter image description here

1 个答案:

答案 0 :(得分:0)

这可能是因为当_id期待admin-on-rest时您正在使用id

记录在案:https://marmelab.com/admin-on-rest/FAQ.html#can-i-have-custom-identifiersprimary-keys-for-my-resources