Skip to content

Commit 193886c

Browse files
refactor: migrate schema fetching to useAsyncData and remove product navigation link.
1 parent 1d20e2d commit 193886c

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

playground/app/layouts/default.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
Nuxt Auto CRUD (Full Stack Example)
1212
</div>
1313
<nav>
14-
<NuxtLink
15-
to="/resource/products"
16-
class="text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-white px-3 py-2"
17-
>Products</NuxtLink>
14+
1815
<LoginModal
1916
label="Admin Login"
2017
color="neutral"

src/runtime/composables/useResourceSchemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useFetch } from '#imports'
1+
import { useAsyncData } from '#imports'
22

33
export const useResourceSchemas = async () => {
4-
const { data: schemas, status, error, refresh } = await useFetch<Record<string, { resource: string, fields: { name: string, type: string, required?: boolean, selectOptions?: string[] }[] }>>('/api/_schema')
4+
const { data: schemas, status, error, refresh } = await useAsyncData('resource-schemas', () => $fetch<Record<string, { resource: string, fields: { name: string, type: string, required?: boolean, selectOptions?: string[] }[] }>>('/api/_schema'))
55

66
const getSchema = (resource: string) => {
77
if (!schemas.value) return undefined

0 commit comments

Comments
 (0)