You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -103,20 +117,44 @@ Small util to check if `response.ok` (status in the range 200-299) used as defau
103
117
104
118
#### `parseResponse`
105
119
106
-
Small util to check to parse typical response like json or text and used as default parse function. If unknow type it returns raw response (for instance images).
120
+
Small util to check to parse typical response like json or text and used as default parse function. If unknown type it returns raw response (for instance images).
107
121
108
122
### Action creator
109
123
110
-
Action creator should return an object with `[CALL_API]` property with `endpoint`, `options` and `types` fields. See [example](#example).
124
+
Action creator should return an object with `[CALL_API]` property with `batch`, `endpoint`, `options` and `types` fields. See [example](#example).
125
+
126
+
#### `[CALL_API].batch`
127
+
128
+
An API endpoints to batch call. `Array` of `Objects` contains `endpoint` and `options` fields in same format as `[CALL_API].endpoint` and `[CALL_API].options`.
129
+
```js
130
+
batch: [
131
+
{ endpoint1, options1 },
132
+
{ endpoint2, options2 },
133
+
],
134
+
```
111
135
112
136
#### `[CALL_API].endpoint`
113
137
114
-
An API endpoint to call. String or function which receives state and returns string.
138
+
An API endpoint to call. Used if batch is not populated. String or function which receives state and returns string.
139
+
```js
140
+
endpoint:'someurl',
141
+
```
142
+
```js
143
+
// calculate url from state
144
+
endpoint: (apiAction, state) =>'someurl',
145
+
```
115
146
116
147
#### `[CALL_API].options`
117
148
118
-
Request options object. Object or function which receives state and returns object.
149
+
Request options object. Used if batch is not populated. Object or function which receives state and returns object.
119
150
It uses [`isomorphic-fetch`](https://github.com/matthew-andrews/isomorphic-fetch) under the hood, so any valid options for [fetch](https://fetch.spec.whatwg.org), like `body`, `credentials`, `headers` and etc.
151
+
```js
152
+
options: { 'method':'PUT'},
153
+
```
154
+
```js
155
+
// calculate options from state
156
+
options: (apiAction, state) => { 'method':'PUT'},
157
+
```
120
158
121
159
#### `[CALL_API].types`
122
160
@@ -260,12 +298,17 @@ Not supported, but might work with [redux-promise](https://github.com/acdlite/re
260
298
2. It not dispatches "programmatic" errors, like errors on endpoint generation.
261
299
3. It gives more control with functions as actions types
262
300
4. Not supports promises, but take look to [redux-promise](https://github.com/acdlite/redux-promise).
301
+
5. Allows to batch API calls
263
302
264
303
6. Want to have base URL?
265
304
266
305
Write a wrapper around your callApi action creator.
267
306
268
-
7. Want to check custom headers or custom parse response?
307
+
7. Want to check custom headers or have custom parse response?
0 commit comments