Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peacetrue/ra-data-spring-rest
data provider for react-admin
https://github.com/peacetrue/ra-data-spring-rest
Last synced: 21 days ago
JSON representation
data provider for react-admin
- Host: GitHub
- URL: https://github.com/peacetrue/ra-data-spring-rest
- Owner: peacetrue
- License: apache-2.0
- Created: 2020-03-18T09:00:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T00:40:31.000Z (almost 2 years ago)
- Last Synced: 2024-04-27T03:40:58.825Z (7 months ago)
- Language: JavaScript
- Size: 364 KB
- Stars: 55
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= ra-data-spring-rest
xiayx
v1.0, 2020-03-18: SNAPSHOTA https://github.com/marmelab/react-admin[React-admin] data provider for backends built with Spring Framework.
== Installation
``npm install --save ra-data-spring-rest``
== Usage
[source%nowrap,javascript]
----
// in App.js
import React from 'react';
import { Admin, Resource } from 'react-admin';
import {springDataProvider, springHttpClient} from 'ra-data-spring-rest';
import { UserList } from './users';const httpClient = springHttpClient();
const dataProvider = springDataProvider('http://path.to.api/',httpClient);
const App = () => (
);export default App;
----`springHttpClient()` use ``fetch`` to send request, +
you can also use ``springHttpClient(fetchUtils.fetchJson)``, +
or customize it:[source%nowrap,javascript]
----
let httpClient = springHttpClient((url, options = {}) => {
options.credentials = 'include';
return fetchUtils.fetchJson(url, options)
.then(response => {
// do some thing you want
return response;
});
});
----== Feature
This package was built to work with the default configurations of a web app using Spring Framework.
It currently supports:* Spring URLs with path variable.
* Sorting with ``SortHandlerMethodArgumentResolver``, using the sort query string parameter.
* Pagination with ``PageableHandlerMethodArgumentResolver``, using the page and size query string parameters.the react-admin Data Provider request example:
* GET_LIST => GET http://my.api.url/posts?keyword=&page=0&size=10&sort=id,asc
* GET_ONE => GET http://my.api.url/posts/123
* GET_MANY => GET http://my.api.url/posts?id=1234&id=5678
* GET_MANY_REFERENCE => GET http://my.api.url/comments?postId=&page=0&size=10&sort=id,asc
* CREATE => POST http://my.api.url/posts
* UPDATE => PUT http://my.api.url/posts/123
* UPDATE_MANY => multiple call UPDATE
* DELETE => DELETE http://my.api.url/posts/123
* DELETE_MANY => multiple call DELETE