A title of about this length
Two lines of text, about as long as the real thing will be once it has arrived from the server.
GET /products/24loadingClick the card to load another product.
GET /users/1 + /postsloadingGET /commentsloadingGET /carts + /usersloadinguseFetch result to :of and describe the shape with sample. The component handles loading, empty responses and errors.<script setup lang="ts">
const posts = useFetch<Posts>('https://dummyjson.com/posts?limit=3', {
lazy: true,
server: false,
})
const sample: Posts = {
posts: [1, 2, 3].map(id => ({
id,
title: 'A title of about this length',
body: 'Two lines of text, about as long as the real thing.',
})),
}
</script>
<template>
<Skeleton :of="posts" :sample>
<template #default="{ data }">
<article v-for="post in data.posts" :key="post.id">
<h3>{{ post.title }}</h3>
<p>{{ post.body }}</p>
</article>
</template>
<template #empty>No posts yet</template>
<template #error="{ error }">{{ error }}</template>
</Skeleton>
</template>
GET /posts?limit=3loadingAdd the module, wrap your markup, done. Everything else is optional.