Skip to content

Instantly share code, notes, and snippets.

@joshuarossi
Created February 22, 2018 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuarossi/7afc1fe8ec22e74539bc01c97fa9a77a to your computer and use it in GitHub Desktop.
Save joshuarossi/7afc1fe8ec22e74539bc01c97fa9a77a to your computer and use it in GitHub Desktop.
Async Middleware, is this ok to do?
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