getToPath does not give correct url
I use
with a route
it will return /myresource/myId
not /myresourrce/show/myId
as I thought it would
Also example of "useGetToPath" online is broken, the resource parameter is not a string but an IResourceItem
2 Replies
Hi @Todilo. 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 knowledge sources, I can address your question about the
getToPath
function and the issues you're experiencing.
1. Regarding the incorrect URL:
The behavior you're experiencing with getToPath
not returning the expected URL is likely due to how your resources are defined. The getToPath
function relies on the resource definitions to construct the URL. Make sure your resource is properly defined with the correct show
action path.
For example, in your <Refine>
component, you should have a resource definition like this:
This definition should match your route structure Relationship Between Resources and Routes (https://refine.dev/docs/guides-concepts/routing/#relationship-between-resources-and-routes-).
2. Regarding the useGetToPath
documentation:
You're correct that there seems to be an issue with the documentation for useGetToPath
. The resource
parameter should indeed be an IResourceItem
object, not a string. This is likely a documentation error useGetToPath Documentation (https://refine.dev/docs/routing/hooks/use-get-to-path/).
To use useGetToPath
correctly, you should do something like this:
Note that select("myresource")
returns the resource object, which is what getToPath
expects Hook Integrations (https://refine.dev/docs/guides-concepts/routing/#hook-integrations).
If you're still experiencing issues after making these adjustments, it might be helpful to double-check your resource definitions and routing setup. If the problem persists, you may want to consider reporting this as a potential bug to the refine team.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@207945811592478720> Kapa.ai is still learning and improving, please let me know how I did by reacting below.