Created
February 13, 2017 15:34
-
-
Save noopnik/51d10a94e05133fb000dda9e1859c6c1 to your computer and use it in GitHub Desktop.
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 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