Skip to content

peacetrue/ra-data-spring-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ra-data-spring-rest

A React-admin data provider for backends built with Spring Framework.

Installation

npm install --save ra-data-spring-rest

Usage

// 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 = () => (
    <Admin dataProvider={dataProvider}>
        <Resource name="users" list={UserList} />
    </Admin>
);

export default App;

springHttpClient() use fetch to send request,
you can also use springHttpClient(fetchUtils.fetchJson),
or customize it:

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:

About

data provider for react-admin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published