-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
3,415 additions
and
1,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Custom plugin | ||
|
||
**NuxtOpenFetch** uses Nuxt plugin to provide fetch clients to the app. | ||
If you need to add non-serializable fetch options which can't be specified in Nuxt config, such as `onRequest`, `onResponse` etc, you can create custom Nuxt plugin. | ||
|
||
First you need disable default plugin: | ||
```ts | ||
export default defineNuxtConfig({ | ||
openFetch: { | ||
disablePlugin: true, | ||
// ... | ||
}, | ||
}) | ||
``` | ||
|
||
For example if you need to add logging on each request: | ||
```ts | ||
export default defineNuxtPlugin(() => { | ||
const { public: { openFetch: clients }} = useRuntimeConfig() | ||
|
||
return { | ||
provide: Object.fromEntries(Object.entries(clients).map(([name, client]) => [ | ||
`${name}Fetch`, | ||
createOpenFetch((options) => ({ | ||
...clients.pets, | ||
...options, | ||
onRequest(ctx) { | ||
console.log('My logging', ctx.request) | ||
return options.onRequest?.(ctx) | ||
} | ||
})) | ||
])) | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
title: 'Advanced' | ||
icon: heroicons-outline:bookmark-alt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
export default defineNuxtConfig({ | ||
modules: ['../src/module'], | ||
extends: ['./pets'], | ||
devtools: { enabled: true } | ||
devtools: { enabled: false }, | ||
openFetch: { | ||
clients: { | ||
foo: { | ||
baseURL: '/petsProxy' | ||
}, | ||
}, | ||
}, | ||
runtimeConfig: { | ||
openFetch: { | ||
pets: { | ||
baseURL: '/petsProxy', | ||
}, | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.