Files
hossein-por-shop/frontend/composables/api/account/useGetAccount.ts
T
2025-01-13 23:44:01 +03:30

30 lines
593 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();
// methods
const handleGetAccount = async () => {
const { data } = await axios.get<GetAccountResponse>(`${API_ENDPOINTS.account.profile}`);
return data;
};
return useQuery({
queryKey: [QUERY_KEYS.account],
queryFn: () => handleGetAccount()
});
};
export default useGetAccount;