const {accessToken} = useAuth() as AuthContextType;
// have to add a line below to make it work but it doesn't make sense to me if I already do it in useAuth
const token = localStorage.getItem(ACCESS_TOKEN) ?? accessToken;
// fetch data
const {isLoading: isLoadingEmail} = useQuery(
['emailData', token],
async () => {
return await axiosClient.get(ACCOUNT_EMAIL_URL, {
params: {
token,
},
});
},
{
onSuccess: (res) => {
setEmail(res.data.email);
},
onError: (err) => {
console.error(err);
setEmailErr('error loading data');
},
},
);
const {accessToken} = useAuth() as AuthContextType;
// have to add a line below to make it work but it doesn't make sense to me if I already do it in useAuth
const token = localStorage.getItem(ACCESS_TOKEN) ?? accessToken;
// fetch data
const {isLoading: isLoadingEmail} = useQuery(
['emailData', token],
async () => {
return await axiosClient.get(ACCOUNT_EMAIL_URL, {
params: {
token,
},
});
},
{
onSuccess: (res) => {
setEmail(res.data.email);
},
onError: (err) => {
console.error(err);
setEmailErr('error loading data');
},
},
);