I try to implement datagrid in tabbed form admin-on-rest
I see request to api looks good:
/api/v1/projectRounds?_end=25&_order=DESC&_sort=id&_start=0&projectId=505
If I try response:
[{"id":13,"projectId":505,"createdAt":"2017-11-17T00:24:34.000Z"}]
In console I have error:
Uncaught TypeError: Cannot read property 'data' of undefined at oneToMany.js:47
try response:
{"data":[{"id":13,"projectId":505,"createdAt":"2017-11-17T00:24:34.000Z"}],"total":1}
Having:
uncaught at handleFetch TypeError: payload.data.map is not a function at ./node_modules/admin-on-rest/lib/reducer/admin/references/oneToMany.js.exports.default
I give code from admin-on-rest example: https://github.com/marmelab/admin-on-rest-demo/blob/a67978a6f69e7dfbb937f66baaa49e787e5853ec/src/visitors/index.js#L82-L93
My code looks like:
<FormTab label="Project rounds">
<ReferenceManyField reference="projectRounds" target="projectId" addLabel={false}>
<Datagrid>
<TextField source="id" />
</Datagrid>
</ReferenceManyField>
</FormTab>
Rest client:
const httpClient = (url, options = {}) => {
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' });
}
const token = localStorage.getItem('token');
options.headers.set('Authorization', `${token}`);
return fetchUtils.fetchJson(url, options);
}
const restClient = jsonServerRestClient(process.env.REACT_APP_API_URL, httpClient);
const App = () => (
<Admin restClient={restClient} authClient={authClient}>
<Resource name="projects" list={ProjectList} edit={ProjectEdit} create={ProjectCreate} />
<Resource name="monitors" list={MonitorList} icon={MonitorIcon}/>
</Admin>
);
Environment:
Admin-on-rest version: 1.3.3
React version: 16.2.0
Could you help me with correct api response or configuring REST client?