Predictable fetch for redux. Used normalizr.
$ npm install multi-routing-api --save
// main-api.origins.js
import { origin, TransportJSON } from 'multi-routing-api';
export const mainResource = origin({
baseUrl: `${window.location.protocol}//${window.location.host}/api/`,
transport: new TransportJSON()
});
// main-api.entities.js
import { schema } from 'multi-routing-api/lib/redux';
export const EntitySandboxComponent = new schema.Entity('sandbox_component');
// resource/components.js
import { EntitySandboxComponent } from '../main-api.entities';
import { mainResource } from '../main-api.origins';
export const resource = mainResource('/components', {}, { responseSchema: [ EntitySandboxComponent ] });
export const getUiAllComponentsAction = resource('GET');