exotic-emerald
exotic-emerald4mo ago

Data Provider with empty resource

I have a useForm const { saveButtonProps, refineCore: { formLoading }, register, control, formState: { errors }, getValues, } = useForm<any>({ refineCoreProps: { resource: '', dataProviderName: 'warehouses', }, }); and provider dataProvider={{ default: dataProvider('http://localhost:8222'), users: dataProvider('http://localhost:8222/auth'), warehouses: warehouseProvider('http://localhost:8222/warehouses') }} why useForm alway add /warehouses after url?
2 Replies
kapa.ai
kapa.ai4mo ago
Hi @Hưng Đinh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The useForm hook in Refine uses the resource prop to determine the API endpoint path. This resource prop is passed to the dataProvider's method as a parameter. If you set the resource prop to an empty string and specify a dataProviderName, the useForm hook will still append the dataProviderName to the base URL. In your case, you have specified warehouses as the dataProviderName. Therefore, the useForm hook will append /warehouses to the base URL, even though you have set the resource prop to an empty string. Here is the relevant information from the knowledge sources: - React-hook-form > useForm > Properties > resource Part 1 (https://refine.dev/docs/packages/react-hook-form/use-form#resource) - Mantine > Hooks > useForm > Properties > resource Part 1 (https://refine.dev/docs/ui-integrations/mantine/hooks/use-form#resource) - Ant-design > Hooks > useForm > Properties > resource Part 1 (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-form#resource) If you want to prevent the useForm hook from appending /warehouses to the base URL, you might need to modify your dataProvider or the way you are using the useForm hook. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@755372117809430589> kapa.ai is still learning and improving, please let us know how it did by reacting below