resource control
i have following useMany hook that i don't want to use the resource url, i want to fetch from specific url, how do i do that
const { data, isLoading, isError } = useMany<IWard, HttpError>({
resource: "products",
ids: districts.map(district => district.DistrictID),
});
2 Replies
Hi @tuanna_. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, if you want to fetch data from a specific URL instead of using the resource URL, you can use the
useCustom
hook. The useCustom
hook allows you to define the URL the request is sent to. Here's an example of how you can use it:
In this example, useApiUrl
is used to get the base URL of the API endpoint. The useCustom
hook is then used to send a request to the specific endpoint. The url
property accepts the endpoint URL, and the method
property accepts the type of method of the endpoint. The config
property accepts values like the query
parameters, and many more.
Please note that you should replace your-specific-endpoint
with the actual endpoint you want to fetch data from.
For more information, you can refer to the useCustom documentation (https://refine.dev/docs/api-reference/core/hooks/data/useCustom).
(Source: Discord support thread: How to have a resource route inside another resource route (https://discord.com/channels/837692625737613362/1125437830701776967))
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below