nazirov91 / ra-strapi-rest

React Admin data provider for Strapi.js
125 stars 40 forks source link

Error for creating ressource #38

Open MaximeDetaille opened 1 year ago

MaximeDetaille commented 1 year ago

Hello,

Im using your provider for strapi and when i want to create a ressource i got an error from strapi because "data" is missing from request

Capture d’écran 2023-05-19 à 10 14 02 Capture d’écran 2023-05-19 à 10 14 13

I updated your provider for making working it by updating this line

Capture d’écran 2023-05-19 à 10 15 37

By this one

Capture d’écran 2023-05-19 à 10 15 59

And all working well. But i really dont know if im doing good ...

timiil commented 1 year ago

same question, use the sample , Article entity, if we dont upload thumbmail image, it will failed in create Article

VadSiam commented 1 month ago

@MaximeDetaille in latest 5.1.3 version (or maybe older) you suppose to use 'transform' method like here:

import { CardActions } from '@mui/material';
import { Create, ListButton, SaveButton, SimpleForm, TextInput, Toolbar, required } from 'react-admin';

const transformUser = data => ({
  data,
});

const CustomToolbar = props => {
  return (
    <Toolbar {...props} style={{ display: 'flex', justifyContent: 'flex-end' }}>
      <SaveButton type="button" transform={transformUser} />
    </Toolbar>
  )
};

export const SchemeCreate = (props) => (
  <Create {...props}>
    <SimpleForm style={{ width: '90vw' }} toolbar={<CustomToolbar />}>
      <TextInput fullWidth source="name" validate={[required()]} />
      <TextInput fullWidth source="defaultPrompt" multiline rows={5} />
    </SimpleForm>
  </Create>
);