HTTP Status Codes
Documentation
Add this plugin to keep track of status codes of your HTTP Requests on resource metadata. This is useful because status codes give you more detail information about your in-flight requests.
Note that you can simply use request objects instead of this plugin. For instance:
This plugin is only useful when you specifically want to track the status on resource metadata.
Usage
First, you need to register this plugin when you call resourceReducer
.
This plugin doesn't come with any custom action types. Instead, it changes the way the state is tranformed with the built-in CRUD action types. Any time that you pass a statusCode
in an action with one of those types, then the code will be stored in your state tree.
Passing the status code looks like the following:
If you're using the Redux Resource XHR library, then you don't need to do anything differently: request status codes are already included in the actions dispatched from that library.
Within your resource metadata, the status code will be available at one of four keys, depending on the CRUD operation being performed:
createStatusCode
readStatusCode
updateStatusCode
deleteStatusCode
On a request object, the code is just available under statusCode
.
Last updated