not making api call for edit basic view antd d

<Edit title={title} dataProviderName='unifiedDataProvider' resource='post' recordItemId='1' footerButtons={() => ( <> <Button>Cancel</Button> <SaveButton {...saveButtonProps} disabled={ joinedColumnList === undefined || joinedColumnList?.length === 0 } > Save </SaveButton> </> )} > <JoinColumnForm formLoading={formLoading} onFinishHandler={onFinishHandler} formProps={formProps} showSearch={true} setOtherColumns={setOtherColumns} otherColumns={otherColumns} column1={column1} column2={column2} form={form} /> </Edit> not calling the get one api for the above edit view from antd
K
kapa.ai50d ago
Hi @jash.s. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The <Edit> component in Refine reads the id information from the route by default. If it cannot read from the URL, which happens when it's used on a custom page, modal, or drawer, recordItemId is used. The recordItemId is necessary for the <RefreshButton> to work properly and fetch the data for the record to be edited. In your case, you have provided recordItemId='1' which should ideally fetch the data for the record with id 1. If it's not making the API call, it could be due to some other issue. You can also customize the save button using the saveButtonProps property. If you want to modify the request sent when the "Save" button is clicked, you can use the useForm hook and modify the onFinish handler. Here's an example from the Refine documentation (https://refine.dev/docs/api-reference/antd/hooks/form/useForm/#how-can-i-change-the-form-data-before-submitting-it-to-the-api):
const {
saveButtonProps,
handleSubmit,
register,
control,
formState: { errors },
refineCore: { onFinish }
} = useForm();

const onFinishHandler = (data: FieldValues) => {
onFinish({
...data,
test: 1
});
};

return (
<Edit
saveButtonProps={{
...saveButtonProps,
onClick: (e: any) => {
handleSubmit(onFinishHandler, () => false)(e);
}
}}
>
// Rest of your code
);
const {
saveButtonProps,
handleSubmit,
register,
control,
formState: { errors },
refineCore: { onFinish }
} = useForm();

const onFinishHandler = (data: FieldValues) => {
onFinish({
...data,
test: 1
});
};

return (
<Edit
saveButtonProps={{
...saveButtonProps,
onClick: (e: any) => {
handleSubmit(onFinishHandler, () => false)(e);
}
}}
>
// Rest of your code
);
In this example, the onFinishHandler modifies the form data before it's submitted to the API. If you're still facing issues, it would be helpful to check the network tab in your browser's developer tools to see if any requests are being made when the Edit view is loaded. If there are any errors, they should show up there. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai50d ago
<@1129363768661516329> kapa.ai is still learning and improving, please let us know how it did by reacting below
E
evident-indigo50d ago
get one api is not called @kapa.ai
K
kapa.ai50d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The getOne API call is typically triggered when you use the useOne hook or when you navigate to an <Edit> or <Show> page in Refine. The getOne method in your data provider is responsible for fetching a single record based on its ID. In your case, you're using the <Edit> component and providing a recordItemId prop. This should trigger a getOne API call to fetch the data for the record with the ID you've specified. If the getOne API call is not being made, it could be due to a few reasons: 1. There might be an issue with your data provider configuration. Ensure that your getOne method in your data provider is correctly implemented. 2. The recordItemId you're providing might not be correct or might not exist in your data source. 3. There might be an issue with the way your routes are set up. If you're using <Edit> on a custom page, ensure that the recordItemId prop is correctly passed. If you're still facing issues, it would be helpful to check the network tab in your browser's developer tools to see if any requests are being made when the Edit view is loaded. If there are any errors, they should show up there. For more information on how to use the getOne method and the useOne hook, you can refer to the Refine documentation (https://refine.dev/docs/guides-concepts/data-fetching#getone-). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai50d ago
<@1129363768661516329> kapa.ai is still learning and improving, please let us know how it did by reacting below
More Posts
Why input request type string?``` export const PointsModal = ({ type, point_id, member_id }: PointsModalProps) => { const { Running app locally fails. Next.js, Google AuthWhen I run this locally I recieve a 404 on the following URL - http://localhost:3000/api/auth/callbaapp-crm implementationHello, I would like to know if there is a way to see an example of the app-crm backend implementatiuseSelect seems to ignore cached values.I have quite simple useSelect, which fetches tenants. I use global config reactQuery: { I want to query more than one resource for Select using useSelectI want to query more than one resource for Select using useSelect, how do I do that?Put intial values:I want to enter the data from the datbase | import React from 'react'; import { IResourceComponentsHow do I add errorNotification to delete buttonShow me how to add errorNotification to DeleteButtonResources on navbar not showing after loginAfter logging in, resources on navbar are not shown until I refresh page. I can't figure it out as nChange page title in browserHow to change page title (next to favicon)?nextjs antd image uploadis there an example of an image upload for nextjs antd image uploadnext-cloudinaryI would like to use the next-cloudinary library to handle uploading images on create / edit formshow to setup with createBrowserRouter react-router-dom v6how to setup with createBrowserRouter react-router-dom v6When on create or edit page goBack button doesn't redirect back to the list of the resourceWhen I am on create or edit page of resource, the goBack button doesn't redirect me to the list of tinfinite scroll for large datahi how I can handle larg data with infinite scrolling without lagging ?`FilterDropdown` + custom filter on Ant Design tableI was going to create a GitHub issue about this but I can't decide what the intended behavior shouldCan the backend code & the DB structure for the CRM template available be made available too?I need to modify the CRM template, would be great if the backend code was made accessible too!