React Admin显示API响应
我是新手到达管理员。因此,我有一个API调用,如下所示。
{ “数据”: { “ type”:“ fory stype”, “ id”:“ userId”, “属性”: { “信用”:0 } } }
我试图在网站页面上显示响应。这是我用于文凭的代码:
<ReferenceManyField addLabel={false} reference="someType" target="users">
<SingleFieldList linkType={false}>
<TextField source='credit' label='User ID' />
</SingleFieldList>
</ReferenceManyField>
错误:对“ getManyReference”的响应必须像{data:[...]},但收到的数据不是数组。 DataProvider的“ GetManyReference”可能是错误的
,因此,我的响应不是集合的数组。
I am new to reach admin. So, I have an api call that return response like below.
{
"data": {
"type": "someType",
"id": "userid",
"attributes": {
"credit": 0
}
}
}
I am trying to display the response on an website page. This the code i am using to diplay:
<ReferenceManyField addLabel={false} reference="someType" target="users">
<SingleFieldList linkType={false}>
<TextField source='credit' label='User ID' />
</SingleFieldList>
</ReferenceManyField>
Error: The response to 'getManyReference' must be like { data : [...] }, but the received data is not an array. The dataProvider is probably wrong for 'getManyReference'
So, My response is not a array of collection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做两件事之一:
1。更改API响应,如果您可以控制API代码
使响应返回
Data
字段的数组,例如:{“数据”:[.....]}
2。收到后,将API响应转换为上述格式客户端
如果您无法更改API代码,则只需将数据格式修改为您需要的内容即可。
You can do one of two things:
1. Change the API Response, if you have control over the API code
Make the response return an array for the
data
field like:{"data": [.....]}
2. Convert the API response to the above format clientside after you receive it
If you can't change the API code then just modify the format of the data into what you need it to be on the client.