useFetchRaw.ts 672 B

123456789101112131415161718192021222324
  1. import { useFetch as _useFetch } from '#app'
  2. import { webSiteFlagRelation, webSiteLanguageRelation } from "../utils/common";
  3. export async function useFetchRaw<T = any>(url: string, options?: any) {
  4. const config = useRuntimeConfig()
  5. const newOptions = {
  6. ...(options ?? {}),
  7. headers: {
  8. ...(options?.headers || {}),
  9. 'Web-Site': webSiteFlagRelation[config.public.appType],
  10. Language: webSiteLanguageRelation[config.public.appType]
  11. },
  12. }
  13. const { data, error, pending, refresh, execute } = await _useFetch<T>(url, newOptions)
  14. return {
  15. data: {
  16. _rawValue: data.value,
  17. },
  18. error,
  19. pending,
  20. refresh,
  21. execute,
  22. }
  23. }