-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Description
So if the Function that calls the refresh authorization fails, React-query isLoading will always be true.
Here is my code:
import axios from "axios";
import createAuthRefreshInterceptor from "axios-auth-refresh";
const axiosInstance = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URI,
withCredentials: true,
});
createAuthRefreshInterceptor(axiosInstance, (failedRequest) =>
axiosInstance.get("/auth/access-token").then((res) => {
return Promise.resolve();
})
);
export const getData = async (url: string, withCredentials?: boolean) => {
return await axiosInstance.get(process.env.NEXT_PUBLIC_API_URI + url);
};``
And this is how i use it using react-query
const { data: userData, isLoading,isError } = useQuery({
queryKey: ["auth"],
queryFn: () => getData("/users/me", true),
});
If I console log isLoading
, it will be always true even tho isError
is true, so the ```isLoading`` `should be false.
Metadata
Metadata
Assignees
Labels
No labels