Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Sep 23, 2024
1 parent f9ae221 commit 7e27671
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frontend/src/hooks/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const generateGetUserQueryKey = (accessToken: string) => {
export const useGetUserQuery = () => {
const dispatch = useDispatch();
const authStore = useSelector(selectAuth);
const [axiosIntercepterAdded, setAxiosIntercepterAdded] = useState(false);
const [axiosInterceptorAdded, setAxiosInterceptorAdded] = useState(false);

useEffect(() => {
const interceptor = axios.interceptors.response.use(
Expand All @@ -39,17 +39,17 @@ export const useGetUserQuery = () => {
}
);

setAxiosIntercepterAdded(true);
setAxiosInterceptorAdded(true);

return () => {
setAxiosIntercepterAdded(false);
setAxiosInterceptorAdded(false);
axios.interceptors.response.eject(interceptor);
};
}, [authStore, dispatch]);

const query = useQuery({
queryKey: generateGetUserQueryKey(authStore.accessToken || ""),
enabled: Boolean(axiosIntercepterAdded && authStore.accessToken),
enabled: Boolean(axiosInterceptorAdded && authStore.accessToken),
queryFn: async () => {
axios.defaults.headers.common["Authorization"] = `Bearer ${authStore.accessToken}`;
const res = await axios.get<GetUserResponse>("/users");
Expand Down

0 comments on commit 7e27671

Please sign in to comment.