mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +00:00
docs: add missing config variable in example (server api) (#4184)
This commit is contained in:
parent
96657388f5
commit
55091b8fdf
@ -85,9 +85,9 @@ For example:
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
const url = process.server ? config.serverUrl : config.clientUrl;
|
const url = process.server ? config.serverUrl : config.clientUrl
|
||||||
|
|
||||||
// Do something with url & isServer.
|
// Do something with url & isServer.
|
||||||
});
|
});
|
||||||
@ -100,6 +100,8 @@ Within the API routes, you can access runtime config by directly importing from
|
|||||||
```ts
|
```ts
|
||||||
import { useRuntimeConfig } from '#nitro'
|
import { useRuntimeConfig } from '#nitro'
|
||||||
|
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
const result = await $fetch('https://my.api.com/test', {
|
const result = await $fetch('https://my.api.com/test', {
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user