Simple read-only static JSON data provider
I looked through the examples, but I'm not able to find any example which just consumes a read-only JSON URL. Is there a data provider available for this?
simple-rest data provider can be used to communicate with a RESTful API. Here's an example of how you can use it:Note: you can ask me a follow up question by @ mentioning me again simple-rest data provider expects the API to follow a certain URL structure and it appends REST API parameters to the URL. Here's the expected URL structure for each method:getList | / resource | , , | |getOne | / resource / id | | |resource | id | |create | / resource | | |update | / resource / id | | |resource / id | | |swizzle command. Here's how you can do it:@refinedev/simple-rest from the list of available data providers./rest-data-provider/index.ts file to customize the data provider.dataProvider prop of the component.Note: you can ask me a follow up question by @ mentioning me again jsonServerDataProviderjsonServerDataProvider<https://api.finefoods.refine.devapiUrlapiUrlapiUrlapiUrlapiUrlapiUrlpaginationsorterssortersfiltersgetManyvariablesvariablesdeleteOnedata: variablesRefinehttps://example.com/data.jsonpagination.modefilters.mode"off"table-matine-basicimport jsonServerDataProvider from "@refinedev/simple-rest";
function App() {
const API_URL = "<https://api.finefoods.refine.dev";>
const dataProvider = jsonServerDataProvider(API_URL);
return (
<BrowserRouter>
...
<Refine
...
dataProvider={dataProvider}
>
...
</BrowserRouter>
);
}
export default App; import { Refine } from "@refinedev/core";
import { dataProvider } from "./rest-data-provider";
const App = () => {
return (
<Refine
dataProvider={dataProvider}
/* ... */
/>
);
}; const {
tableProps: { pagination, ...tableProps },
} = useTable<IPost>({
pagination: {
mode: "off",
},
filters: {
mode: "off",
},
}); const {
getHeaderGroups,
getRowModel,
setOptions,
setPageIndex,
getPageCount,
refineCore: {
tableQueryResult: { data: tableData },
},
...table
} = useTable({
columns,
manualPagination: false,
getPaginationRowModel: getPaginationRowModel(),
refineCoreProps: {
pagination: {
mode: "off",
},
filters: {
mode: "off",
},
},
}); <Pagination
position="right"
total={getPageCount()}
page={table.getState().pagination.pageIndex + 1}
onChange={(number) => {
setPageIndex(number - 1);
}}
/>