Skip to content

Commit fa9fe2b

Browse files
committed
dispatch action instead of using next in middleware chain.
1 parent f6d9ca6 commit fa9fe2b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const createMiddleware = ({
6767
responseSuccess = successInterceptor,
6868
responseFailure = failureInterceptor,
6969
}) => (
70-
({ getState }) => next => (action) => {
70+
({ dispatch, getState }) => next => (action) => {
7171
if (!action[CALL_API]) {
7272
return next(action);
7373
}
@@ -90,7 +90,7 @@ export const createMiddleware = ({
9090
const [requestType, successType, failureType] = types;
9191

9292
// dispatch request type
93-
next(actionWith(
93+
dispatch(actionWith(
9494
requestType, [apiAction, getState()]
9595
));
9696

@@ -100,10 +100,10 @@ export const createMiddleware = ({
100100

101101
return Promise.all(promises)
102102
.then(
103-
responses => next(actionWith(
103+
responses => dispatch(actionWith(
104104
successType, [apiAction, getState()], batchMode ? responses : responses[0]
105105
)),
106-
error => next(actionWith(
106+
error => dispatch(actionWith(
107107
failureType, [apiAction, getState()], error
108108
))
109109
);

0 commit comments

Comments
 (0)