How to make API call using Data Provider?
Considering the following code, how do I make an API call to a specific endpoint such as
stores/blockstores/block using my data provider's "custom" method?type StoreList = {
id: number;
name: string;
cnpj: string;
sellin: string;
status: string;
target: string;
};
export default function StoresList() {
const { tableProps } = useTable<StoreList>({
syncWithLocation: true,
});
const deactivateStore = ({ status, id }: StoreList) => {
// Make api call to `stores/${id}/status` here
};
return (
<List>
<Table {...tableProps} rowKey="id">
{/* Other columns... */}
<Table.Column
dataIndex="actions"
render={(_, record: BaseRecord) => (
<Button
onClick={() => deactivateStore(record)}
size="small"
type="link"
>
Deactivate store
</Button>
)}
/>
</Table>
</List>
);
}type StoreList = {
id: number;
name: string;
cnpj: string;
sellin: string;
status: string;
target: string;
};
export default function StoresList() {
const { tableProps } = useTable<StoreList>({
syncWithLocation: true,
});
const deactivateStore = ({ status, id }: StoreList) => {
// Make api call to `stores/${id}/status` here
};
return (
<List>
<Table {...tableProps} rowKey="id">
{/* Other columns... */}
<Table.Column
dataIndex="actions"
render={(_, record: BaseRecord) => (
<Button
onClick={() => deactivateStore(record)}
size="small"
type="link"
>
Deactivate store
</Button>
)}
/>
</Table>
</List>
);
}