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
8 changed files
with
31 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
toc: false | ||
--- | ||
|
||
# Use custom fetch composable | ||
|
||
This example shows a convenient wrapper for the useFetch composable from nuxt. It allows you to customize the fetch request with default values and user authentication token. | ||
|
||
::sandbox{repo="nuxt/nuxt" branch="main" dir="examples/other/use-custom-fetch-composable" file="composables/useCustomFetch.ts"} |
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,16 @@ | ||
|
||
<script setup lang="ts"> | ||
const { data } = await useCustomFetch<object>('/beers') | ||
</script> | ||
|
||
<template> | ||
<NuxtExampleLayout example="other/use-custom-fetch-composable"> | ||
<h1 class="text-xl opacity-50"> | ||
Nuxt custom fetch | ||
</h1> | ||
|
||
<pre class="text-left text-xs">{{ data }}</pre> | ||
</NuxtExampleLayout> | ||
</template> |
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
...er/custom-fetch-composable/nuxt.config.ts → ...se-custom-fetch-composable/nuxt.config.ts
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,6 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
|
||
modules: [ | ||
'@nuxt/ui' | ||
] | ||
}) |
File renamed without changes.
File renamed without changes.