Files
hossein-por-shop/frontend/composables/api/account/useGetAccount.ts
T
marzban-dev af9736f3e7 Updated
2025-01-14 21:03:34 +03:30

32 lines
658 B
TypeScript

// imports
import { useQuery } from "@tanstack/vue-query";
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
// types
export type GetAccountResponse = Product;
const useGetAccount = () => {
// state
const { $axios: axios } = useNuxtApp();
const { token } = useAuth();
// methods
const handleGetAccount = async () => {
const { data } = await axios.get<GetAccountResponse>(`${API_ENDPOINTS.account.profile}`);
return data;
};
return useQuery({
enabled: !!token.value,
queryKey: [QUERY_KEYS.account],
queryFn: () => handleGetAccount()
});
};
export default useGetAccount;