Skip to content

Commit

Permalink
Fix Nuxt middleware (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper authored Feb 4, 2024
1 parent b99c3c4 commit 0e358f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/pages/tutorials/github-oauth/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ Then, create a global middleware in `middleware/auth.global.ts` to populate it.
// middleware/auth.global.ts
export default defineNuxtRouteMiddleware(async () => {
const user = useUser();
user.value = await $fetch("/api/user");
const { data } = await useFetch("/api/user");
if (data.value) {
user.value = data.value;
}
});
```

Expand Down
5 changes: 4 additions & 1 deletion docs/pages/tutorials/username-and-password/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ Then, create a global middleware in `middleware/auth.global.ts` to populate it.
// middleware/auth.global.ts
export default defineNuxtRouteMiddleware(async () => {
const user = useUser();
user.value = await $fetch("/api/user");
const { data } = await useFetch("/api/user");
if (data.value) {
user.value = data.value;
}
});
```

Expand Down

0 comments on commit 0e358f8

Please sign in to comment.