ratty-blush
ratty-blush14mo ago

how to get :id

event/v1/event/:id/ticket-class/new/ how to get :id in the code, I want to create a ticket-class list but the :id cannot be obtained.
No description
3 Replies
kapa.ai
kapa.ai14mo ago
Hi @angga30prabu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, you can obtain the id from the current URL using the useParsed hook. Here is an example of how you can do this:
import { useParsed } from "@refinedev/core";

const { id } = useParsed();
import { useParsed } from "@refinedev/core";

const { id } = useParsed();
In this example, id will hold the value of :id from the current URL. If you want to use this id in a form, you can pass it to the useForm hook like this:
import { useForm } from "@refinedev/antd";
import { useParsed } from "@refinedev/core";

const { id } = useParsed();

useForm({
resource: "custom-resource",
id,
});
import { useForm } from "@refinedev/antd";
import { useParsed } from "@refinedev/core";

const { id } = useParsed();

useForm({
resource: "custom-resource",
id,
});
In this example, the useForm hook is used with a resource named "custom-resource" and the id obtained from the URL. You can find more information about this in the refine documentation (https://refine.dev/docs/api-reference/antd/hooks/form/useForm/). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai14mo ago
<@550882194181193746> kapa.ai is still learning and improving, please let us know how it did by reacting below
exotic-emerald
exotic-emerald14mo ago
hello @angga30prabu bot code seems valid. is it worked ?