Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)),
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;
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',