why can't use underline as name?
why can't use underline as name?
{
name: 'temp_products',
list: 'temp-products',
create: '/temp-products/create',
edit: '/temp-products/edit/:id',
show: '/temp-products/show/:id',
10 Replies
Hi @yasuaki_jp. 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's no explicit restriction mentioned about using an underline in the
name
property of a resource in Refine. The name
property is a string value that identifies a resource in the API. It's used to interact with the data in a resource using an endpoint determined by the name
.
Here's an example from the Refine documentation (https://refine.dev/docs/core/refine-component#resources):
In your case, using temp_products
as the name
should work as expected, as long as there's a corresponding endpoint in your API. However, it's important to ensure that the name
matches the endpoint in your API. For example, if your API endpoint is <https://api.example.com/temp-products
,> then you should use temp-products
as the name
.
If you're experiencing issues, it might be due to other factors not related to the use of an underline in the name
. It's recommended to check your API endpoint and ensure that it matches the name
you're using in your resource definition.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------harsh-harlequin•6mo ago
@kapa.ai
sider render as temp_products
but I wrote /temp-products
Let me check the knowledge base for you. One moment! :books:
----------------------
The
name
property you provide in the resources
array is used by Refine to create routes and also to display in the sidebar. If you provide temp_products
as the name
, it will be displayed as such in the sidebar.
If you want to display a different name in the sidebar, you can use the options
property with a label
field in your resource definition. The label
field allows you to specify a custom label for the resource that will be displayed in the sidebar.
Here's how you can do it:
In this example, "Temp Products" will be displayed in the sidebar instead of "temp_products".
Please note that the label
field does not affect the API endpoint. The name
field is still used to interact with the API endpoint.
For more information, you can refer to the Refine documentation (https://refine.dev/docs/core/refine-component#resources).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@449197041306828802> kapa.ai is still learning and improving, please let us know how it did by reacting below
harsh-harlequin•6mo ago
sider link to temp_products but acctually temp-products
@kapa.ai
sider link to temp_products but acctually temp-products
Let me check the knowledge base for you. One moment! :books:
----------------------
The
name
property in the resources
array is used by Refine to create routes and also to display in the sidebar. If you provide temp_products
as the name
, it will be displayed as such in the sidebar and the route will be /temp_products
.
If you want the route to be /temp-products
but display as temp_products
in the sidebar, you can use the meta
property with a label
field in your resource definition. The label
field allows you to specify a custom label for the resource that will be displayed in the sidebar.
Here's how you can do it:
In this example, "Temp Products" will be displayed in the sidebar and the route will be /temp-products
.
Please note that the label
field does not affect the API endpoint. The name
field is still used to interact with the API endpoint.
For more information, you can refer to the Refine documentation (https://refine.dev/docs/guides-concepts/faq#how-can-i-add-an-item-to-the-sider-component).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@449197041306828802> kapa.ai is still learning and improving, please let us know how it did by reacting below
harsh-harlequin•6mo ago
@kapa.ai
but acctually table name is temp_products
Let me check the knowledge base for you. One moment! :books:
----------------------
If your table name in the database is
temp_products
but you want the route in your Refine application to be temp-products
, you need to handle this mapping in your API layer.
Refine uses the name
property in the resources
array to interact with the API and to create routes. If you provide temp-products
as the name
, Refine will make requests to the temp-products
endpoint and also create routes like /temp-products
, /temp-products/create
, /temp-products/edit/:id
, etc.
In your API layer, you need to map the temp-products
endpoint to the temp_products
table in your database. This way, when Refine makes a request to the temp-products
endpoint, your API will interact with the temp_products
table.
Here's an example of how you can define your resource in Refine:
In this example, Refine will make requests to the temp-products
endpoint and your API needs to handle these requests and interact with the temp_products
table in your database.
For more information, you can refer to the Refine documentation (https://refine.dev/docs/core/refine-component#resources).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@449197041306828802> kapa.ai is still learning and improving, please let us know how it did by reacting below