Skip to content

Commit

Permalink
fix(initializeNetworkHelpers): runtime error when specifying getToken
Browse files Browse the repository at this point in the history
Fixed runtime error `this.getToken()` is undefined, which happened
when overriding the built-in method
  • Loading branch information
adrienharnay authored Mar 8, 2018
1 parent d639e2b commit 4d3d6e9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/internals/action-creator/thunk/generateActionCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ const generateActionCreator = (
...getNetworkHelpers(),
...(networkHelpers || {}),
};
const {
[`request${method}`]: requestMethod,
handleError,
handleStatusCode,
} = combinedNetworkHelpers;

dispatch(actionCreatorActions.REQUEST(normalizedURL, resourceId));

Expand All @@ -42,8 +37,11 @@ const generateActionCreator = (
);
const finalBody = beforeHookReturn || body;

const res = await fetch(formattedURL, requestMethod(finalBody));
handleStatusCode(res);
const res = await fetch(
formattedURL,
combinedNetworkHelpers[`request${method}`](finalBody),
);
combinedNetworkHelpers.handleStatusCode(res);
const data = res.status !== 204 ? await res.json() : {};
const {
entities: normalizedPayload,
Expand Down Expand Up @@ -86,7 +84,7 @@ const generateActionCreator = (
} catch (error) {
dispatch(actionCreatorActions.FAIL(normalizedURL, resourceId));

handleError(error, dispatch);
combinedNetworkHelpers.handleError(error, dispatch);
safeCall(onError, error);
return { error };
}
Expand Down

0 comments on commit 4d3d6e9

Please sign in to comment.