Trigger useCustom on click
Is there any way to trigger an useCustom on click on a button ?
Note: you can ask me a follow up question by @ mentioning me again useCustomuseCustomuseCustomuseCustomhandleClickimport { useCustom, useApiUrl } from "@refinedev/core";
const YourComponent = () => {
const apiUrl = useApiUrl();
const handleClick = () => {
const { data, isLoading } = useCustom({
url: `${apiUrl}/your-endpoint`,
method: "get",
config: {
headers: {
"x-custom-header": "foo-bar",
},
query: {
title: "Foo bar",
},
},
});
}
return (
<button onClick={handleClick}>Click me</button>
);
}