Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meadow/redux-api-middleware

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meadow/redux-api-middleware

API middleware for redux

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
5
Weekly downloads
 
Created
Source

Redux API Middleware

redux-api-middleware provides a middleware function to use as part of the redux dispatch chain. It is intended for use with the Meadow API promise library to provide a middleware to dispatch actions for REQUEST, SUCCESS, and FAILURE.

Installation

npm install @meadow/redux-api-middleware

Usage

Configure store:

import apiMiddleware from '@meadow/redux-api-middleware';
import thunkMiddleware from 'redux-thunk';

const middleware = [thunkMiddleware, apiMiddleware];

const createStoreWithMiddleware = applyMiddleware(...middleware)(createStore);

Action:

import {
  FETCH_ORGANIZATION_REQUEST,
  FETCH_ORGANIZATION_SUCCESS,
  FETCH_ORGANIZATION_FAILURE
} from './constants';
import { CALL_API } from '@meadow/redux-api-middleware';

export function fetchOrganization () {
  return (dispatch, getState) => {
    return dispatch({
      [CALL_API]: {
        types: [
          FETCH_ORGANIZATION_REQUEST,
          FETCH_ORGANIZATION_SUCCESS,
          FETCH_ORGANIZATION_FAILURE
        ],
        promise: Meadow.getOrganization()
      }
    });
  };
}

Keywords

FAQs

Package last updated on 15 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc