Reputation: 35
React-Admin: 2.9.5
i have next code
const CreateUserComponentBase = (props) => {
const { ...rest } = props
return (
<SimpleForm
validate={validate}
{...rest}
>
{/*...code*/}
</SimpleForm>
)
}
const UserCreateBase = (props: any) => {
const { setTitle, ...rest } = props
return (
<Create {...rest}>
<CreateUserForm {...rest} isEdit={false} />
</Create>
)
};
I am sending a request on server And my API generates an error message, and how do I output this message if React-Admin only "Server Error" shows it
Upvotes: 1
Views: 1457
Reputation: 2547
I don't know on v2.9.5 but in the latest version you can use onSuccess
and onFailure
callbacks like so
const handleFailure = (error) => {
notify(`Something bad happened: ${error}`), 'error');
};
const handleSuccess = (data) => {
notify('Success!');
redirect('show', props.basePath, data.id);
refresh();
};
return (
<Edit
{...props}
onFailure={handleFailure}
onSuccess={handleSuccess}
>
...
</Edit>
);
Upvotes: 1