export const useApi = () => {
  const config = useRuntimeConfig()
  const { locale } = useI18n()

  const apiFetch = async <T>(endpoint: string, options: Record<string, any> = {}) => {
    return await $fetch<T>(`${config.public.apiUrl}${endpoint}`, {
      ...options,
      headers: {
        'X-API-Key': config.public.apiKey as string,
        'Accept-Language': locale.value,
        'Content-Type': 'application/json',
        ...options.headers,
      },
    })
  }

  return { apiFetch }
}
