I'm starting to use the react-admin
package.
I am blocked in my development because I would like to make a Select
with the data of another Resource
. And that's why I use ReferenceField
but I don't know why I get this error when I use this element.
Error: The response to 'GET_LIST' must be like { data : [{ id: 123, ...}, ...] }, but at least one received data item do not have an 'id' key. The dataProvider is probably wrong for 'GET_LIST
Here is the data that I receive from my API:
[{"_id":"5e3ec3baa6480d002b24ea90","name_promo":"test","years":"2019-01-01T00:00:00.000Z","__v":0}]
For information, I use the Provider ra-data-json-server
Here is my code:
import React from 'react';
import {
Create,
SimpleForm,
TextInput,
ReferenceInput,
SelectInput,
} from 'react-admin';
const CreateUser = (props) => (
<Create {...props}>
<SimpleForm>
<TextInput source="lastName" label="Prénom" />
<TextInput source="firstName" label="Nom" />
<TextInput source="email" label="Email" />
<TextInput source="role" label="Role" />
<ReferenceInput label="Session" source="id" reference="sessions" >
<SelectInput optionText="name_promo"/>
</ReferenceInput >
</SimpleForm>
</Create>
);
export default CreateUser;