optimistic-gold
optimistic-gold8mo ago

How to define a custom api endpoint for a resource?

I have a resource
{
name: "suppliers",
list: "/dashboard/suppliers",
create: "/dashboard/suppliers/create",
edit: "/dashboard/suppliers/edit/:id",
show: "/dashboard/suppliers/show/:id",
meta: {
canDelete: true,
},
},
{
name: "suppliers",
list: "/dashboard/suppliers",
create: "/dashboard/suppliers/create",
edit: "/dashboard/suppliers/edit/:id",
show: "/dashboard/suppliers/show/:id",
meta: {
canDelete: true,
},
},
Which trying to GET data from
/api/v1/suppliers?_end=10&_start=0
/api/v1/suppliers?_end=10&_start=0
How to change this path to
/api/v1/dictionaries/suppliers
/api/v1/dictionaries/suppliers
3 Replies
kapa.ai
kapa.ai8mo ago
Hi @mflash.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, the resource prop is usually used as an API endpoint path. This is passed to the dataProvider as a parameter. However, the way it is handled depends on your dataProvider implementation. If you want to change the API endpoint path for a specific resource, you would need to modify your dataProvider to handle this. Unfortunately, the extracts provided do not contain specific information on how to modify the dataProvider for this purpose. However, there is a discussion in the extracts about using different data providers for different resources. This might be a possible solution for your case. You can create a custom data provider for the "suppliers" resource that uses the desired endpoint path. Here is the link to the documentation mentioned in the extract: Multiple Data Providers (https://refine.dev/docs/api-reference/core/providers/data-provider/#multiple-data-providers) Please note that this is a general direction based on the information available in the extracts. For a more specific solution, you might need to refer to the complete documentation or seek help from the refine community. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai8mo ago
<@204169884727246849> kapa.ai is still learning and improving, please let us know how it did by reacting below
xenial-black
xenial-black8mo ago
Hey @mflash. , you can change the name to dictionaries/suppliers and then add identifier property as suppliers The endpoint will change but you will still be able to reference it as suppliers