我不是在寻求帮助,我只是认为您在自定义JSON服务器实现中有问题。我正在使用:" admin-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-on-p>"
这是我的app.js:
...
import restClient from './restClient';
const App = () => (
<Admin
title="Glasses"
dashboard={Dashboard}
menu={Menu}
restClient={restClient}
authClient={authClient}
>
<Resource name="products" list={ProductList} />
</Admin>
);
RESTCLIENT.JS文件是https://github.com/marmelab/admin-on-rest/blob/blob/master/src/rest/jsonserver.js的副本P>
import {
GET_LIST,
GET_ONE,
GET_MANY,
GET_MANY_REFERENCE,
CREATE,
UPDATE,
DELETE,
fetchUtils
} from 'admin-on-rest';
const { queryParameters, fetchJson } = fetchUtils;
...
其余的restclient.js是一个逐一,如git" jsonserver.js"。
当我在菜单中单击"产品"时,我收到了一个通知:" REST响应必须包含一个数据密钥",并且在控制台中:"警告:缺少密钥的翻译:" REST响应必须包含数据密钥">
现在,当然看起来服务器在响应中没有返回"数据"对象,但是问题是没有请求!当我转到我的"网络"选项卡(在Chrome Console filter到所有网络中(时,我没有看到对API的任何请求,因此如何接收此类错误?
我在我的retclient.js file(jsonserver.js(的底部的第一行中添加了" console.log":
return (type, resource, params) => {
console.log('test'); // THIS WHAT I ADDED
// json-server doesn't handle WHERE IN requests, so we fallback to calling GET_ONE n times instead
if (type === GET_MANY) {
return Promise.all(params.ids.map(id => httpClient(`${apiUrl}/${resource}/${id}`)))
.then(responses => ({ data: responses.map(response => response.json) }));
}
const { url, options } = convertRESTRequestToHTTP(type, resource, params);
return httpClient(url, options)
.then(response => convertHTTPResponseToREST(response, type, resource, params));
};
但是"测试"未印刷到控制台。
有建议吗?我做错了吗?
可以帮助的视频:https://nimbus.everhelper.me/client/notes/notes/share/982310/35f8rwpu6qohrftn8h1hRESTCLIENT.JS文件:http://pasted.co/2024e00f
谢谢您的高级。
狮子座。
所以我的错误是我在没有URL的情况下声明了Admin组件内的RESTCLIENT属性。
这是正确的方法:
const App = () => (
<Admin
title="Express Glasses"
dashboard={Dashboard}
menu={Menu}
restClient={restClient('http://UrlToApi.com/api')}
authClient={authClient}
>
<Resource name="products" list={ProductList} />
</Admin>
);