Skip to content

Instantly share code, notes, and snippets.

@noopnik
Created February 13, 2017 15:34
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 noopnik/51d10a94e05133fb000dda9e1859c6c1 to your computer and use it in GitHub Desktop.
Save noopnik/51d10a94e05133fb000dda9e1859c6c1 to your computer and use it in GitHub Desktop.
export const authInterceptor = ({ dispatch }) => next => action => {
if (action.status === 401) {
Promise.resolve(dispatch(refreshToken()).then(() =>
next(action)
, (error) => {
console.log(error);
dispatch(logout());
}
));
} else {
return next(action);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment