How to get params from url in refine?

I want to access the params from url in edit page. How can I achieve that? My edit page url is s/locations/edit/1425 now I want to access the id 1425. I am using react-router-v6
5 Replies
flat-fuchsia
flat-fuchsia3y ago
Hi @dipbazz, can u try this ? you should see your params in params object
import { useRouterContext } from '@pankod/refine-core'

const { useParams } = useRouterContext()
const params = useParams()
console.log(params)
import { useRouterContext } from '@pankod/refine-core'

const { useParams } = useRouterContext()
const params = useParams()
console.log(params)
flat-fuchsia
flat-fuchsia3y ago
oh, sorry. useResource is much easier and it's best practice 🙏 thank you
Omer
Omer3y ago
useResource is sufficient to access the "id" parameter, but @alicanerdurmaz 's way can be used to access custom parameters
fascinating-indigo
fascinating-indigoOP3y ago
Thank you @alicanerdurmaz and @Omer for your response.

Did you find this page helpful?