import { useFetch as _useFetch } from '#app'
import { webSiteFlagRelation, webSiteLanguageRelation } from "../utils/common";

export async function useFetchRaw<T = any>(url: string, options?: any) {
  const config = useRuntimeConfig()
  const newOptions = {
    ...(options ?? {}),
    headers: {
      ...(options?.headers || {}),
      'Web-Site': webSiteFlagRelation[config.public.appType],
      Language: webSiteLanguageRelation[config.public.appType]
    },
  }
  const { data, error, pending, refresh, execute } = await _useFetch<T>(url, newOptions)
  return {
    data: {
      _rawValue: data.value,
    },
    error,
    pending,
    refresh,
    execute,
  }
}
