Custom api endpoint with useUpdate
Is it possible to provide mutate a custom api endpoint when using the useUpdate data hook? I want to get the flexibility of useCustom but be able to make the call in response to a user action like pressing a button.
2 Replies
Hi @Molag's Meat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, it is possible to provide a custom API endpoint when using the
useUpdate
data hook in refine. You can achieve this by specifying the resource
parameter, which will be passed to the update
method from the dataProvider
as a parameter. This parameter is usually used as an API endpoint path.
Here is an example of how you can use the useUpdate
hook with a custom API endpoint:
In this example, the resource
parameter is set to "custom-endpoint"
, which will be used as the API endpoint path. The id
parameter specifies the record to update, and the values
parameter contains the data to update.
For more information, you can refer to the useUpdate documentation (https://refine.dev/docs/data/hooks/use-update/#resource-).
If you need more flexibility similar to useCustom
, you can also consider using the useCustomMutation
hook, which allows you to specify both the url
and method
parameters:
For more details, refer to the useCustomMutation documentation (https://refine.dev/docs/data/hooks/use-custom-mutation/#url-).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@224018850419572736> kapa.ai is still learning and improving, please let us know how it did by reacting below