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
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -366,8 +366,8 @@ The `[RSAA].types` property controls the output of `redux-api-middleware`. The s
366
366
- `fetch` may throw an error: the RSAA definition is not strong enough to preclude that from happening (you may, for example, send in a `[RSAA].body` that is not valid according to the fetch specification — mind the SHOULDs in the [RSAA definition](#redux-standard-api-calling-actions));
367
367
- a network failure occurs (the network is unreachable, the server responds with an error,...).
368
368
369
-
If such an error occurs, a different *request* FSA will be dispatched (*instead* of the one described above). It will contain the following properties:
370
-
- `type`: the string constant in the first position of the `[RSAA].types` array;
369
+
If such an error occurs, a *failure* FSA will be dispatched containing the following properties:
370
+
- `type`: the string constant in the last position of the `[RSAA].types` array;
371
371
- `payload`: a [`RequestError`](#requesterror) object containing an error message;
372
372
- `error:true`.
373
373
@@ -666,6 +666,7 @@ For example, if you want the status code and status message of a unsuccessful AP
666
666
}
667
667
}
668
668
```
669
+
669
670
By default, *failure* FSAs will not contain a `meta` property, while their `payload` property will be evaluated from
670
671
```js
671
672
(action, state, res) =>
@@ -674,6 +675,9 @@ By default, *failure* FSAs will not contain a `meta` property, while their `payl
674
675
)
675
676
```
676
677
678
+
679
+
Note that *failure* FSAs dispatched due to fetch errors will not have a `res` argument into `meta` or `payload`. The `res` parameter will exist for completed requests that have resulted in errors, but not for failed requests.
680
+
677
681
### Exports
678
682
679
683
The following objects are exported by `redux-api-middleware`.
@@ -898,6 +902,9 @@ $ npm install && npm test
898
902
## Upgrading from v2.0.x
899
903
900
904
- The `CALL_API` alias has been removed
905
+
- Error handling around failed fetches has been updated (#175)
906
+
- Previously, a failed `fetch` would dispatch a `REQUEST` FSA followed by another `REQUEST` FSA with an error flag
907
+
- Now, a failed `fetch` will dispatch a `REQUEST` FSA followed by a `FAILURE` FSA
0 commit comments