Skip to content

Commit

Permalink
docs: add note for usage (nuxt#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Nov 15, 2021
1 parent 5786949 commit b69ebbb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/content/3.docs/1.usage/1.data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Nuxt provides `useFetch`, `useLazyFetch`, `useAsyncData` and `useLazyAsyncData` to handle data fetching within your application.

::alert{icon=👉}
**`useFetch`, `useLazyFetch`, `useAsyncData` and `useLazyAsyncData` only works during `setup` or `Lifecycle Hooks`**
::

## `useAsyncData`

Within your pages, components and plugins you can use `useAsyncData` to get access to data that resolves asynchronously.
Expand Down Expand Up @@ -57,10 +61,6 @@ Within your pages, components and plugins you can use `useFetch` to get universa

This composable provides a convenient wrapper around `useAsyncData` and `$fetch` and automatically generates a key based on url and fetch options and infers API response type.

::alert{icon=👉}
**`useFetch` only works during `setup` or `Lifecycle Hooks`**
::

### Usage

```ts
Expand Down
4 changes: 4 additions & 0 deletions docs/content/3.docs/1.usage/4.nuxt-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function useMyComposable () {

Plugins also receive `nuxtApp` as the first argument for convenience. [Read more about plugins.](/docs/directory-structure/plugins)

::alert{icon=👉}
**`useNuxtApp` (on server side) only works during `setup`, inside Nuxt plugins or `Lifecycle Hooks`**
::

## Providing helpers

You can provide helpers to be usable across all composables and application. This usually happens within a nuxt plugin.
Expand Down
4 changes: 4 additions & 0 deletions docs/content/3.docs/1.usage/5.runtime-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ const config = useRuntimeConfig()

**🛑 Security note:** Never use example above if `API_AUTH_TOKEN` is a private config. Even if you use `privateRuntimeConfig`, you have to be still careful you do not expose such config to either payload or html!

::alert{icon=👉}
**`useRuntimeConfig` only works during `setup` or `Lifecycle Hooks`**
::

### API routes

Within the API routes, you can access runtime config by directly importing from virtual `#config`.
Expand Down

0 comments on commit b69ebbb

Please sign in to comment.