import { useRoute } from 'vue-router'; import { AsyncData, type Language } from '../../runtime'; import type { IPlaylistData } from '../../types'; export const useFetchPlaylistsById = async (apiMethod: (...args: any[]) => Promise) => { const route = useRoute(); const id = computed(() => String(route.params['playlistId'])); const key = AsyncData.PlaylistById; const stateKey = computed(() => `data-${key}-${id.value}`); const lang = useLang() as Language; const { data, status, error, refresh } = await useAsyncData( stateKey.value, () => useApiFetcher( stateKey.value, apiMethod, id.value, lang )(), ); return { data, status, error, refresh }; };