How to use ra-data-fakerest - 3 common examples

To help you get started, we’ve selected a few ra-data-fakerest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marmelab / react-admin / examples / simple / src / dataProvider.js View on Github external
import fakeRestProvider from 'ra-data-fakerest';

import data from './data';
import addUploadFeature from './addUploadFeature';

const dataProvider = fakeRestProvider(data, true);
const uploadCapableDataProvider = addUploadFeature(dataProvider);
const sometimesFailsDataProvider = new Proxy(uploadCapableDataProvider, {
    get: (target, name) => (resource, params) => {
        // add rejection by type or resource here for tests, e.g.
        // if (name === 'delete' && resource === 'posts') {
        //     return Promise.reject(new Error('deletion error'));
        // }
        return uploadCapableDataProvider[name](resource, params);
    },
});
const delayedDataProvider = new Proxy(sometimesFailsDataProvider, {
    get: (target, name) => (resource, params) =>
        new Promise(resolve =>
            setTimeout(
                () =>
                    resolve(sometimesFailsDataProvider[name](resource, params)),
github fizix-io / ra-customizable-datagrid / demo / src / dataProvider.js View on Github external
import jsonRestProvider from 'ra-data-fakerest';

import data from './data';
import addUploadFeature from './addUploadFeature';

const dataProvider = jsonRestProvider(data, true);
const uploadCapableDataProvider = addUploadFeature(dataProvider);
const sometimesFailsDataProvider = (type, resource, params) =>
  new Promise((resolve, reject) => {
    // add rejection by type or resource here for tests, e.g.
    // if (type === 'DELETE' && resource === 'posts') {
    //     return reject('deletion error');
    // }
    return resolve(uploadCapableDataProvider(type, resource, params));
  });
const delayedDataProvider = (type, resource, params) =>
  new Promise(resolve =>
    setTimeout(() => resolve(sometimesFailsDataProvider(type, resource, params)), 1000),
  );

export default delayedDataProvider;
github marmelab / timeline-react-admin / src / App.js View on Github external
import React, { Component } from 'react';
import { Admin, Resource, ListGuesser } from 'react-admin';
import fakeRestDataProvider from 'ra-data-fakerest';

import Timeline from './Timeline';

const dataProvider = fakeRestDataProvider(
    {
        posts: [],
        events: [
            {
                id: 1234,
                label: 'modified post "Hello World"',
                createdAt: '2019-01-10T17:15:56.000Z',
                author: {
                    name: 'John Doe',
                    email: 'jitewaboh@lagify.com',
                },
            },
            {
                id: 1233,
                label: 'created new post "Hello World"',
                createdAt: '2019-01-10T16:34:00.000Z',

ra-data-fakerest

JSON Server data provider for react-admin

MIT
Latest version published 3 days ago

Package Health Score

93 / 100
Full package analysis

Popular ra-data-fakerest functions