node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

redux-routed-api-middleware

npm npm Dependency Status devDependency Status

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');