Created
February 22, 2018 03:44
-
-
Save joshuarossi/7afc1fe8ec22e74539bc01c97fa9a77a to your computer and use it in GitHub Desktop.
Async Middleware, is this ok to do?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const AsyncMiddleware = store => next => async action => { | |
switch (action.type) { | |
case FETCH: | |
const response = await fetch(action.payload) | |
dispatch({type: WEB_RESPONSE, payload: response}) | |
break; | |
default: | |
break; | |
} | |
next(action) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment