Create a custom hook like useMany or useOne without sending ids
I have this
And this
But I want to have something like
To avoid sendig and empty array of ids or an invalid id.
2 Replies
Hi @Sebastos. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the extracts, there isn't a direct way to create a custom hook like
useMany
or useOne
without sending ids in Refine. The useMany
and useOne
hooks are designed to fetch multiple records and a single record respectively, based on the ids provided.
However, if you want to fetch data from a resource without specifying ids, you can use the useList
or useInfiniteList
hooks. These hooks are designed to fetch a list of records from a resource. Here's an example:
If you need to make custom API requests, you can use the useCustom
hook. This hook allows you to make custom requests to your API. Here's an example:
Please note that the useCustom
hook requires a custom
function that returns an object with url
and method
properties.
For more information, you can refer to the Refine documentation (https://refine.dev/docs/data/hooks/use-custom/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@689846866837373077> kapa.ai is still learning and improving, please let us know how it did by reacting below