redux-routed-api-middleware
v2.3.0
Published
redux api middleware for separate your api routes, api actions, and interceptors. provide state normalization, db reducer
Downloads
18
Maintainers
Readme
redux-routed-api-middleware
Predictable fetch for redux. Used normalizr.
$ npm install redux-routed-api-middleware --save
// main-api.origins.js
import { ResourceOrigin, TransportJSON } from 'redux-routed-api-middleware';
export const mainResource = ResourceOrigin({
baseUrl: `${window.location.protocol}//${window.location.host}/api/`,
defaultTransport: new TransportJSON()
});
// main-api.entities.js
import { schema } from 'redux-routed-api-middleware';
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');