I\'m trying to use multiple dataproviders in a react-admin project but I have an error:
Warning: Missing translation for key: \"dataProvider is not a functio
You're not calling the dataProvider you found, you're calling the mapping object from your array. You can fix it like this:
import simpleRestProvider from 'ra-data-simple-rest';
const dataProviders = [
{ dataProvider: simpleRestProvider('http://path.to.foo.api1'), resources: ['users1'] },
{ dataProvider: simpleRestProvider('http://path.to.foo.api2'), resources: ['users2'] },
];
export default (type, resource, params) => {
const dataProviderMapping = dataProviders.find(dp => dp.resources.includes(resource));
return dataProviderMapping.dataProvider(type, resource, params);
};