Created
May 31, 2022 05:07
-
-
Save sourabhbagrecha/4047ec71f1f244900c08f20927b9e6c0 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
const { useQuery } = require("react-query"); | |
const useAuthedQuery = (...options) => { | |
const query = useQuery(...options); | |
if (query?.error?.response?.status === 401) { | |
// Insert custom access-token refresh logic here. For now, we are | |
// just refreshing the page here, so as to redirect them to the | |
// login page since their token is now expired. | |
window.location.reload(); | |
} | |
return query; | |
} | |
export default useAuthedQuery; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment