adverse-sapphire
adverse-sapphire13mo ago

Getting created resource after create operation

What's the best way to get a created resource instance once I perform a create operation
2 Replies
kapa.ai
kapa.ai13mo ago
Hi @ansellmax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, after performing a create operation, you can redirect to the list page of the resource. This is one of the useful features enabled by the resource property. The value passed to the resource property is used to determine the active resource from the resources array. This array is optional for API interactions but enables features such as redirecting to the list page after create and update operations. Here's an example of how you can use the resource property with the useCreateMany hook:
const { mutate } = useCreateMany();

mutate({
resource: "categories",
});
const { mutate } = useCreateMany();

mutate({
resource: "categories",
});
In this example, the resource parameter will be passed to the create method from the dataProvider as a parameter. It is usually used as an API endpoint path but it all depends on how you handle the resource in the create method. For more information, you can refer to the refine documentation (https://refine.dev/docs/api-reference/general-concepts) and the useCreateMany documentation (https://refine.dev/docs/api-reference/core/hooks/data/useCreateMany). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@585815815526285331> kapa.ai is still learning and improving, please let us how it did by reacting below