docs: add missing config variable in example (server api) (#4184)

This commit is contained in:
Sébastien Chopin 2022-04-07 23:16:42 +02:00 committed by GitHub
parent 96657388f5
commit 55091b8fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: {