Save 2 resources at same time
Hello, I'm using ant design with stripe4, how can I save 2 resources at same time?
useForm hook allows you to handle form submissions and the useMutation hook allows you to perform custom mutations on your data. You might be able to use these hooks to perform operations on multiple resources.useMutation hook provided by Refine. This hook allows you to perform custom mutations on your data. useMutation to insert data into multiple resources. useMutation:handleSave is a function that saves the same data to two different resources. You would call this function when you want to save your data.useMutation documentation (https://refine.dev/docs/data/hooks/use-mutation).handleSaveimport { useMutation } from "@refinedev/react";
const MyComponent: React.FC = () => {
const [mutate, { isLoading }] = useMutation();
const handleSave = async (data) => {
// Save to the first resource
await mutate({
resource: "resource1",
type: "create",
payload: { data },
});
// Save to the second resource
await mutate({
resource: "resource2",
type: "create",
payload: { data },
});
};
// Rest of your component here
};