quickest-silver
quickest-silver14mo ago

Customize error message when an action button is clicked in the list page

hi guys, I am having a little trouble with customizing the error message in the toast. when a user hit the delete action button in the list page, error is shown and I want to customize that. I looked into onError function in authProvider but can't able to customize error, any body could help?
6 Replies
kapa.ai
kapa.ai14mo ago
Hi @alfaz_muhammed. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai14mo ago
---------------------- To customize the error message for the delete action, you can use the errorNotification prop in the useDelete hook. The onError function in the authProvider is not relevant for this case. Here's an example of how to customize the error message using the errorNotification prop:
const { mutate } = useDelete();

mutate({
errorNotification: (data, values, resource) => {
return {
message: `Something went wrong when deleting ${data.id}`,
description: "Error",
type: "error",
};
},
});
const { mutate } = useDelete();

mutate({
errorNotification: (data, values, resource) => {
return {
message: `Something went wrong when deleting ${data.id}`,
description: "Error",
type: "error",
};
},
});
You can find more information about this in the useDelete documentation (https://refine.dev/docs/api-reference/core/hooks/data/useDelete). Make sure to have the NotificationProvider (https://refine.dev/docs/api-reference/core/providers/notification-provider/) in your application for the error notification to work. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Notification Provider | refine
refine let's you set a notification API by providing the notificationProvider property to the `` component.
kapa.ai
kapa.ai14mo ago
<@763439201353596968> kapa.ai is still learning and improving, please let us how it did by reacting below
quickest-silver
quickest-silver14mo ago
actually the delete case is just a use case. I actually want to customize the error message shown in toast whenever an error occur in my refine app. is there any general area or something?
metropolitan-bronze
metropolitan-bronze14mo ago
you can ask up to.. i think 3 questions per thread by tagging the bot FYI
inland-turquoise
inland-turquoise14mo ago
Hey @alfaz_muhammed There are no general settings yet. We're working on that. You can use errorNotification for now. We also have i18n support. You can also change notification messages from here. https://refine.dev/docs/api-reference/core/providers/i18n-provider/