From 5e5f9aa732d5f1c3cf0f6c51b93e74fc22ac8fbf Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Wed, 4 Jun 2025 19:12:54 +0330 Subject: [PATCH] added cart fetching only if login --- frontend/composables/api/orders/useGetCartOrders.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/composables/api/orders/useGetCartOrders.ts b/frontend/composables/api/orders/useGetCartOrders.ts index 03ebe0a..c5c35f2 100644 --- a/frontend/composables/api/orders/useGetCartOrders.ts +++ b/frontend/composables/api/orders/useGetCartOrders.ts @@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/vue-query"; import { API_ENDPOINTS, QUERY_KEYS } from "~/constants"; +import { useAuth } from "../auth/useAuth"; // types @@ -12,17 +13,18 @@ const useGetCartOrders = () => { const { $axios: axios } = useNuxtApp(); + const { token } = useAuth(); + // methods const handleGetCartOrders = async () => { - const { data } = await axios.get( - API_ENDPOINTS.orders.cart.get_all - ); + const { data } = await axios.get(API_ENDPOINTS.orders.cart.get_all); return data; }; return useQuery({ queryKey: [QUERY_KEYS.cart], + enabled: !!token.value, queryFn: () => handleGetCartOrders(), }); };