https://github.com/sakoh/redux-api-utility-library
A utility library for handling API Requests and Async Actions with Redux
https://github.com/sakoh/redux-api-utility-library
api async higher-order-functions higher-order-reducers middleware react redux utility-library
Last synced: 6 months ago
JSON representation
A utility library for handling API Requests and Async Actions with Redux
- Host: GitHub
- URL: https://github.com/sakoh/redux-api-utility-library
- Owner: sakoh
- License: apache-2.0
- Created: 2018-01-15T22:46:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-17T22:47:20.000Z (about 8 years ago)
- Last Synced: 2025-10-10T12:46:12.803Z (9 months ago)
- Topics: api, async, higher-order-functions, higher-order-reducers, middleware, react, redux, utility-library
- Language: TypeScript
- Homepage: http://sakoh.github.io/redux-api-utility-library
- Size: 4.42 MB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redux API Utility Library (RAUL)
[](https://travis-ci.org/sakoh/redux-api-utility-library)
[](https://codecov.io/gh/sakoh/redux-api-utility-library)
Redux API Utility Library (RAUL) is a library of higher order reducers, an API middleware, TypeScript data types,
and other utility functions to make building a Redux Application involving asynchronous calls to RESTful APIs
more simple.
## Install
```bash
npm i --save redux-api-utility-library
```
## Higher Order Reducers
```js
import { createRequestReducer } from 'redux-api-utility-library/dist/reducers'
const users = createRequestReducer('users')
```
Now there is a reducer created fully equipped to deal with all the standard actions dispatched by the `apiMiddleware`.
## Middleware
```js
import { apiMiddleware } from 'redux-api-utility-library/dist/middleware'
const store = createStore(
users: createRequestReducer('users'),
{},
applyMiddleware(apiMiddleware),
)
```
## Action creators
```js
import { createRequestAction } from 'redux-api-utility-library/dist/actions'
const action = createRequestAction('users', {
method: 'GET',
url: '/users',
baseURL: 'https://jsonplaceholder.typicode.com',
})
```
this action when dispatched get handled by the `apiMiddleware` makes the network requests equivalent to the keys passed in as the second argument.