Skip to content

Commit

Permalink
Merge pull request #42 from flickerleap/feature-add-meta-object
Browse files Browse the repository at this point in the history
Feature add meta object
  • Loading branch information
BenitoP authored Jun 11, 2018
2 parents 0f63db8 + 469be59 commit b5c5f36
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-admin-template",
"version": "1.1.27",
"version": "1.1.28",
"description": "",
"main": "dist/bundle.js",
"style": "dist/styles.css",
Expand Down
8 changes: 5 additions & 3 deletions src/helpers/createFSAConverter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const createFSAConverter = (successType, failureType) => {
export const createFSAConverter = (successType, failureType, meta = {}) => {
return (response) => {
if (!response.ok) {
return response.json().then((payload) => ({
Expand All @@ -7,7 +7,8 @@ export const createFSAConverter = (successType, failureType) => {
status: response.status,
response: payload
},
type: failureType
type: failureType,
meta: meta
}));
}

Expand All @@ -17,7 +18,8 @@ export const createFSAConverter = (successType, failureType) => {
const createSuccessType = (payload) => {
return {
payload: payload,
type: successType
type: successType,
meta: meta
};
};

Expand Down
4 changes: 2 additions & 2 deletions src/middleware/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const apiMiddleware = store =>
return next(action);
}

let {endpoint, method, body, headers = {}} = callAPI;
let {endpoint, method, body, headers = {}, meta = {}} = callAPI;
const {types} = callAPI;

headers["Content-Type"] = "application/json";
Expand Down Expand Up @@ -46,7 +46,7 @@ export const apiMiddleware = store =>
credentials: "same-origin"
})
// Reads the body stream into Flux Standard Action
.then(createFSAConverter(successType, failureType))
.then(createFSAConverter(successType, failureType, meta))
.then(
attemptRefresh({
action,
Expand Down

0 comments on commit b5c5f36

Please sign in to comment.