我有两个终点
API/说明
API /主题
在我的服务器上,模型指令有一个名为subject的引用字段。
在react管理前端,我想创建(crud)一个新的指令实例。
跟随
this tutorial
我已经实现了我的指令创建如下
export const InstructionCreate = (props) => (
<Create title="New Instruction"{...props}>
<SimpleForm>
<ReferenceInput label="Subject" source="subject" reference="subject/">
<SelectInput optionText="name" />
</ReferenceInput>
</SimpleForm>
</Create>
当我从chrome控制台的networktab下呈现create组件时,我可以看到返回的主题对象列表。
该列表有两个对象(从服务器中提取)和一个属性“name”
但是,我得到一个控制台错误
uncaught typeerror:无法读取未定义的属性“data”
上述错误发生在
如果有人需要我的app.js,我可以从中成功地crud api/subject端点
const App = () => (
<Admin
dataProvider={dataProvider}
<Resource name="subject" title="Subjects" list={SubjectList} create={SubjectCreate} edit={SubjectEdit} icon={GroupIcon}/>
<Resource name="instruction" title="Instructions" list={InstructionList} edit={InstructionEdit} create={InstructionCreate} icon={InstructionIcon}/>
</Admin>
);
get api/subject-返回字典列表
[
{
“ID”:2,
“name”:“主题2”
}
{
“id”:1,
“name”:“主题1”
}
]