redux-small-axios-middleware
1.0.3 • Public • Published redux-small-axios-middleware
Redux middleware for async request with axios
install
npm i -S redux-small-axios-middleware
Usage
in createStore.js
import axios from 'axios';
import reduxSmallAxiosMiddleware from 'redux-small-axios-middleware';
let store = createStore(
reducers,
applyMiddleware(
...
reduxSmallAxiosMiddleware(axios),
...
)
)
in anyAction.js
export someActions = () => {
return {
type: 'GET_DATA_TEST',
onSuccessCallback: function(){
console.log("success")
},
onErrorCallback: function(){
console.log("error")
},
options: {
url: '<your URL>',
},
}
}
Options object is axios request config
in dispaching.js
import { someActions } from '../anyAction.js'
dispatch(someActions());
Package Sidebar
Install
npm i redux-small-axios-middleware
Weekly Downloads