Javascript REST上的管理员:嵌套创建路由不工作?

Javascript REST上的管理员:嵌套创建路由不工作?,javascript,reactjs,admin-on-rest,Javascript,Reactjs,Admin On Rest,我当前的设置如下所示: <Route exact path="/stream" render={(routeProps) => <StreamList hasCreate resource="stream" {...routeProps} />} />, <Route exact path="/stream/create" render={(routeProps) => <StreamCreate resource="stream" {...rou

我当前的设置如下所示:

<Route exact path="/stream" render={(routeProps) => <StreamList hasCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/create" render={(routeProps) => <StreamCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id" render={(routeProps) => <StreamEdit hasDelete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id/delete" render={(routeProps) => <Delete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/query/:id" component={StreamQueryEdit} />,
<Route exact path="/config/how/antonym" render={(routeProps) => <AntonymList hasCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/create" render={(routeProps) => <AntonymCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id" render={(routeProps) => <AntonymEdit resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id/delete" render={(routeProps) => <Delete resource="antonym" {...routeProps} />} />
if (this.props.children) {
    return this.props.children
}
export const AntonymCreate = (props) => (
    <Create {...props} title="Create">
    ...
    </Create>
);
httpClient.js:

restClient.js

…所以我在那个部门很基础

我现在有两条路线如下所示:

<Route exact path="/stream" render={(routeProps) => <StreamList hasCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/create" render={(routeProps) => <StreamCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id" render={(routeProps) => <StreamEdit hasDelete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id/delete" render={(routeProps) => <Delete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/query/:id" component={StreamQueryEdit} />,
<Route exact path="/config/how/antonym" render={(routeProps) => <AntonymList hasCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/create" render={(routeProps) => <AntonymCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id" render={(routeProps) => <AntonymEdit resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id/delete" render={(routeProps) => <Delete resource="antonym" {...routeProps} />} />
if (this.props.children) {
    return this.props.children
}
export const AntonymCreate = (props) => (
    <Create {...props} title="Create">
    ...
    </Create>
);
/config/how/
中,这些嵌套路由的呈现方式如下:

<Route exact path="/stream" render={(routeProps) => <StreamList hasCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/create" render={(routeProps) => <StreamCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id" render={(routeProps) => <StreamEdit hasDelete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id/delete" render={(routeProps) => <Delete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/query/:id" component={StreamQueryEdit} />,
<Route exact path="/config/how/antonym" render={(routeProps) => <AntonymList hasCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/create" render={(routeProps) => <AntonymCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id" render={(routeProps) => <AntonymEdit resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id/delete" render={(routeProps) => <Delete resource="antonym" {...routeProps} />} />
if (this.props.children) {
    return this.props.children
}
export const AntonymCreate = (props) => (
    <Create {...props} title="Create">
    ...
    </Create>
);
“列表”、“编辑”和“删除”路由的工作方式与此处的预期相同。唯一的问题是,一旦我导航到创建路由,我会从服务器收到一个500错误

事实证明,经过一些调查后,框架没有将此路由识别为创建路由,而是将其视为对id“create”的
GET
请求

以下是我追踪到的问题:

这表明,出于某种原因,rest上的管理员将此请求视为GET请求。这也会导致代码通过
Edit.js
(而不是“创建”),我真的不知道为什么

我试图找到设置
类型
参数的地方,看看是什么导致了这种行为……但到目前为止运气不好


尤其奇怪的是,在这种情况下,列表和编辑路由都可以正常工作。这只是创建路线…

请确保您的AntonymCreate组件具有如下形式:

<Route exact path="/stream" render={(routeProps) => <StreamList hasCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/create" render={(routeProps) => <StreamCreate resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id" render={(routeProps) => <StreamEdit hasDelete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/:id/delete" render={(routeProps) => <Delete resource="stream" {...routeProps} />} />,
<Route exact path="/stream/query/:id" component={StreamQueryEdit} />,
<Route exact path="/config/how/antonym" render={(routeProps) => <AntonymList hasCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/create" render={(routeProps) => <AntonymCreate resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id" render={(routeProps) => <AntonymEdit resource="antonym" {...routeProps} />} />
<Route exact path="/config/how/antonym/:id/delete" render={(routeProps) => <Delete resource="antonym" {...routeProps} />} />
if (this.props.children) {
    return this.props.children
}
export const AntonymCreate = (props) => (
    <Create {...props} title="Create">
    ...
    </Create>
);
导出常量反义词create=(道具)=>( ... );
这可能就是它不起作用的原因。

应该在aor github页面上询问Bug报告。在therehi@kunalpareek提出问题……老实说,我不确定这是否是一个真正的bug,或者我只是在这里做错了什么……我自己也有一些嵌套路由的问题。我在rest客户端创建了一个虚拟资源,然后在那里设置了正确的URL。他们解决了这个问题,将我送回stackoverflow,甚至没有评论这是一个bug还是我做错了什么@kunalpareek:DYeah他们做得很大方:)你应该看看法国人Francois是如何与zany一起关闭peeps的思想。但有时他们不这样认为。我想这可能是其中之一。嗨,谢谢你的建议。不幸的是,我的创建路线已经是这样了。因为我不能在评论中发布代码,所以我将提供一个屏幕截图:。