useFetchRaw.ts 583 B

1234567891011121314151617181920212223
  1. import { useFetch as _useFetch } from '#app'
  2. import { webSiteFlagRelation } 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. },
  11. }
  12. const { data, error, pending, refresh, execute } = await _useFetch<T>(url, newOptions)
  13. return {
  14. data: {
  15. _rawValue: data.value,
  16. },
  17. error,
  18. pending,
  19. refresh,
  20. execute,
  21. }
  22. }