React Admin显示API响应

发布于 2025-01-27 05:21:37 字数 598 浏览 2 评论 0原文

我是新手到达管理员。因此,我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2025-02-03 05:21:37

您可以做两件事之一:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文