export function readBook(id) {
return function(dispatch) {
type: actionTypes.READ_RESOURCES_PENDING,
// `request` would be whatever function you are using to make HTTP
// requests. It could be `window.fetch()`, axios, superagent, xhr,
// or anything else that you prefer.
request('/some-url', (err, res) => {
// Different libraries attach the status code to different properties.
// It is usually either `res.status` or `res.statusCode`. You do not
// need to check both properties if you know which one your library uses.
if (err || res.statusCode >= 400 || res.status >= 400) {
type: actionTypes.READ_RESOURCES_FAILED,
statusCode: res.statusCode
// Check to see if the request was cancelled, or if it succeeded, then
// dispatch the appropriate action here.