Package Exports
- ra-jsonapi-client
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ra-jsonapi-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ra-jsonapi-client
A JSONAPI compatible data provider for react-admin.
Features
Currently only the basic actions are supported:
GET_LISTGET_ONECREATEUPDATEDELETE
Installation
# via npm
npm install ra-jsonapi-client
# via yarn
yarn add ra-jsonapi-clientUsage
Import this package, set the base url and pass it as the dataProvider to react-admin.
//in app.js
import React from "react";
import { Admin, Resource } from "react-admin";
import jsonapiClient from "ra-jsonapi-client";
const dataProvider = jsonapiClient('http://localhost:3000');
const App = () => (
<Admin dashboard={Dashboard} dataProvider={dataProvider}>
...
</Admin>
);
export default App;Options
This client allows you to set some optional settings as the second parameter:
// Configure some settings.
const settings = { ... };
// Pass it as the second parameter after the base URL.
const dataProvider = jsonapiClient('http://localhost:3000', settings);Total count
Since JSONAPI does not specify a standard for the total count key in the meta object, you can set it with:
const settings = { total: 'total-count' };Which will work for:
{
"data": { ... },
"meta": {
"total-count": 436
}
}If this option is not set it will fall back to total.
TODO
- Allow custom headers (e.g. Authorization)
- Allow filtering