// composables/useHadithaSearchComposable.js import { useStorage } from "@vueuse/core"; export const useHadithaSearchComposable = (url, options = {}) => { const loading = ref(false); // Track loading state const data = ref(null); const error = ref(null); const status = ref(null); // Get the authentication token (e.g., from a cookie or local storage) // const token = useCookie('auth-token') // Assuming you store the token in a cookie let token = useStorage("id_token", "GuestAccess"); const config = useRuntimeConfig(); console.info(config); const baseURL = config.public.NUXT_PUBLIC_BASE_URL + config.public.NUXT_PUBLIC_API_NAME; // Add headers to the request const headers = { Authorization: token.value, ...options.headers, // Merge with any existing headers }; // Use useFetch with the headers return useFetch(url, { ...options, baseURL: baseURL, headers, }); };