data-provider
所属分类:后台框架
开发工具:TypeScript
文件大小:8KB
下载次数:0
上传日期:2022-02-21 04:41:35
上 传 者:
sh-1993
说明: 用于 React管理的以laravel objectionjs为中心的JSONAPI数据提供程序。
(A laravel objectionjs-focused JSONAPI dataprovider for react-admin.)
文件列表:
.editorconfig (130, 2022-02-21)
.npmignore (14, 2022-02-21)
LICENSE.md (1074, 2022-02-21)
package.json (909, 2022-02-21)
src (0, 2022-02-21)
src\defaultSettings.ts (156, 2022-02-21)
src\errors.ts (418, 2022-02-21)
src\helpers.ts (1156, 2022-02-21)
src\index.ts (3330, 2022-02-21)
src\interceptors.ts (486, 2022-02-21)
tsconfig.json (574, 2022-02-21)
yarn.lock (3892, 2022-02-21)
# data-provider
A laravel/objectionjs-focused JSONAPI dataprovider for [react-admin](https://github.com/marmelab/react-admin). Currently supports all dataproviders methods:
- `getList`
- `getMany`
- `getManyReference`
- `getOne`
- `create`
- `update`
- `delete`
This packages also exposes an axios client for custom endpoints.
## Usage
1. Install the package `npm i -D @jodaz_/data-provider`.
2. Import and set the base url, retrieve the endpoint object and pass it as the dataprovider for react-admin.
``` javascript
//in app.js
import React from "react";
import { Admin, Resource } from "react-admin";
import dataProvider from '@jodaz_/data-provider';
const { endpoints, client } = dataProvider('http://your.api.endpoint', {
offsetPageNum: -1,
// Other axios configs
}, 'Your token name used in localstorage');
const App = () => (
...
);
export default App;
```
## API
```
dataProvider(api, customConfigs, tokenName);
```
- `api`: a valid API route **REQUIRED**.
- `customConfigs`: an object of custom axios configs.
- `tokenName`: a valid token name used when retrieving a Bearer token from localStorage.
- `endpoints`: exports all the required resources for react-admin.
- `client`: exports an axios client for custom api endpoint calls.
## Other custom configs
- `"offsetPageNum": number` an offset for page counter
## Credits
I must give a huge thanks to [@henvo](https://github.com/henvo/ra-jsonapi-client). I literally copy-pasted his original repo and adapted to my own codebase.
近期下载者:
相关文件:
收藏者: