redux-small-axios-middleware
v1.0.3
Published
Redux middleware for async request with axios
Downloads
8
Readme
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, //custom reducers
applyMiddleware(
//all middlewares
...
reduxSmallAxiosMiddleware(axios),
...
)
)
in anyAction.js
export someActions = () => {
return {
type: 'GET_DATA_TEST', //require
onSuccessCallback: function(){
console.log("success")
},
onErrorCallback: function(){
console.log("error")
},
options: { //
url: '<your URL>', //require
},
}
}
Options object is axios request config
in dispaching.js
import { someActions } from '../anyAction.js'
//...
dispatch(someActions());