frail-apricot
frail-apricot4w ago

In useCustom, useList and useSelect hooks (antd), how can I check if request was succesful?

In useCustom, useList and useSelect hooks, how can I check if request was succesful?
2 Replies
kapa.ai
kapa.ai4w ago
Hi @chachi. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To check if a request was successful in the useCustom, useList, and useSelect hooks in refine (Ant Design), you can utilize the successNotification property. This property allows you to customize the success notification that appears when the data is fetched successfully. Here are examples for each hook: useCustom Hook The successNotification property in the useCustom hook can be used to check if the request was successful and to customize the success notification message.
useCustom({
successNotification: (data, values) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
useCustom({
successNotification: (data, values) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
useList Hook Similarly, the successNotification property in the useList hook can be used to check if the request was successful and to customize the success notification message.
useList({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
useList({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
useSelect Hook The successNotification property in the useSelect hook can also be used to check if the request was successful and to customize the success notification message.
useSelect({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
useSelect({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully fetched.`,
description: "Success with no errors",
type: "success",
};
},
});
Important Note For the successNotification property to work, you need to have the NotificationProvider (https://refine.dev/docs/notification/notification-provider/) set up in your application. For more details, you can refer to the following documentation: - useCustom Hook (https://refine.dev/docs/data/hooks/use-custom/#successnotification) - useList Hook (https://refine.dev/docs/data/hooks/use-list/#successnotification) - useSelect Hook (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-select/#successnotification) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@95552725294518272> kapa.ai is still learning and improving, please let us know how it did by reacting below