// composables/useHadithaSearchComposable.js import { useStorage } from "@vueuse/core"; export const useHadithaSearchComposable = (url: string, options = {}) => { // 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(); 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, headers, }); // return useAsyncData(keyName, async () => { // return await $fetch(url, { // ...options, // baseURL, // headers, // }); // }); };