【发布时间】:2018-08-02 17:32:52
【问题描述】:
我正在使用 react-admin 和 Spring REST 作为数据 API 构建应用程序。我处于具有相对 cmets 的 Product 对象的典型情况。
在显示产品的元素中,我添加了 ReferenceManyField 以显示该产品的 cmets。但问题是:根据参考文档,该组件获取调用 cmets 列表的 cmets 并查找具有父亲 id 的 cmets:
https://marmelab.com/react-admin/Fields.html#referencemanyfield
但由于我的 Spring REST 为一种特定产品产生了类似的东西:
{
"id" : 1,
"description" : "Description of Product 1",
"price" : 50045.0,
"title" : "Title of product 1",
"additionaldata" : [ ],
"pimages" : [ ],
"_links" : {
"self" : {
"href" : "http://localhost:8080/products/1"
},
"product" : {
"href" : "http://localhost:8080/products/1"
},
"pcomments" : {
"href" : "http://localhost:8080/products/1/pcomments"
},
"vendor" : {
"href" : "http://localhost:8080/products/1/vendor"
}
}
}
逻辑是相反的,我们找到要调用的 URI 以查找该特定产品的 cmets 列表。
如何让 ReferenceManyField 调用 http://localhost:8080/products/1/pcomments 来获取该产品的 cmets?
【问题讨论】: