https://github.com/anpleenko/redux-small-axios-middleware
https://github.com/anpleenko/redux-small-axios-middleware
axios middleware redux
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/anpleenko/redux-small-axios-middleware
- Owner: anpleenko
- License: mit
- Created: 2017-03-24T09:20:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T06:37:50.000Z (about 9 years ago)
- Last Synced: 2026-03-25T09:03:33.403Z (3 months ago)
- Topics: axios, middleware, redux
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/redux-small-axios-middleware
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-small-axios-middleware
### Redux middleware for async request with axios
[](https://nodei.co/npm/redux-small-axios-middleware/)
[](https://travis-ci.org/vaeum/redux-small-axios-middleware)
[![NPM version][npm-image]][npm-url]
[![Downloads][downloads-image]][npm-url]
### install
```bash
npm i -S redux-small-axios-middleware
```
### Usage
in createStore.js
```javascript
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
```javascript
export someActions = () => {
return {
type: 'GET_DATA_TEST', //require
onSuccessCallback: function(){
console.log("success")
},
onErrorCallback: function(){
console.log("error")
},
options: { //
url: '', //require
},
}
}
```
Options object is axios [request config](https://github.com/mzabriskie/axios#request-config)
in dispaching.js
```javascript
import { someActions } from '../anyAction.js'
//...
dispatch(someActions());
```
[downloads-image]: https://img.shields.io/npm/dm/redux-small-axios-middleware.svg
[npm-url]: https://www.npmjs.com/package/redux-small-axios-middleware
[npm-image]: https://img.shields.io/npm/v/redux-small-axios-middleware.svg