我是一个初级节点开发人员,正在尝试在rest上使用admin,以便为我的json api快速运行一个管理面板。但是,我所有更新请求都使用patch而不是put。我尝试修改restClient中的更新方法,但这似乎是错误的(为简洁起见,删除了其余方法)
export default (apiUrl, httpClient = fetchJson) => {
const convertRESTRequestToHTTP = (type, resource, params) => {
let url = ''
const options = {}
switch (type) {
case UPDATE:
url = `${apiUrl}/${resource}/${params.id}`
options.method = 'PATCH'
options.body = JSON.stringify(params.data)
break
return { url, options }
}
}对我来说,这是有意义的,但当我试图编辑一个对象时,我得到了HTTP/1.1 404 Not Found <pre>Cannot PUT </pre>,我知道这在以前的版本中是不可能的,但我读了这个https://marmelab.com/blog/2017/03/10/admin-on-rest-0-9.html#http-patch,但对它的工作原理有点困惑?我想我只是不知道从哪里开始。
发布于 2017-06-12 04:35:51
如果现在问题仍然存在,请检查一些我正在使用的地方来设置我的customRestClient。
// App.js
import customRestClient from './customRestClient';在我的例子中,我使用httpClient来添加自定义头:
import httpClient from './httpClient';如下所示:
const restClient = customRestClient('my_api_url', httpClient);最后:
<Admin title="Admin Panel" restClient={restClient}>https://stackoverflow.com/questions/44423087
复制相似问题