Nuxt/docs/content/3.api/1.composables/use-fetch.md
Clément Ollivier 9a0fc57724
docs: update sitemap (#4063)
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
2022-04-06 07:56:08 +02:00

741 B

useFetch

const {
  data: Ref<DataT>,
  pending: Ref<boolean>,
  refresh: (force?: boolean) => Promise<void>,
  error?: any
} = useFetch(url: string, options?)

Available options:

  • key: Provide a custom key
  • Options from ohmyfetch
    • method: Request method
    • params: Query params
    • headers: Request headers
    • baseURL: Base URL for the request
  • Options from useAsyncData
    • lazy
    • server
    • default
    • pick
    • transform

The object returned by useFetch has the same properties as that returned by useAsyncData (see above).

::ReadMore{link="/guide/features/data-fetching"} ::

::ReadMore{link="/api/composables/use-async-data"} ::