redux-api-request
v2.0.13
Published
Redux middleware for making api requests
Downloads
28
Readme
Redux middleware for making api requests
Installation
npm install --save redux-api-request
Usage
Using redux-api-request in your application is easy:
# install middleware
import createApiRequest from 'redux-api-request'
import thunkMiddleware from 'redux-thunk'
import reducer from './reducer'
const apiRequestMiddleware = createApiRequest()
const createStoreWithMiddleware = applyMiddleware(
thunkMiddleware,
apiRequestMiddleware
)(createStore)
const store = createStoreWithMiddleware(reducer)
# action creator
import { API_REQUEST } from 'redux-api-request/action_types'
export const signin = (email, password) => ({
type: API_REQUEST,
method: 'POST',
endpoint: '/admin/signin',
body: { email, password },
request: SIGNIN_REQUEST,
success: SIGNIN_SUCCESS,
failure: SIGNIN_FAILURE
})
Author & Credits
redux-api-request was originally written by Greg Kops and is based upon his work with Think Topography and The Cornell Cooperative Extension of Tompkins County