Bumped dependencies & added error display for Posts

This commit is contained in:
Flycro
2022-02-05 22:59:52 +01:00
parent 9db5b5781e
commit 94140719b8
4 changed files with 1092 additions and 1041 deletions

View File

@@ -10,7 +10,7 @@
<div>
<h1>Blog</h1>
<div>
<ei:spinner-3 v-if="post.loading" class="text-4xl text-fly animate-spin" />
<ei:spinner-3 v-if="post.loading" class="text-4xl text-fly-600 dark:text-fly-500 animate-spin" />
<ul
v-if="post.postList && post.loading === false" key="test" v-motion class="list-none"
:initial="{ opacity: 0 }" :enter="{opacity: 1, transition: {delay: 0.5,} }"
@@ -33,6 +33,9 @@
>
No Posts found
</div>
<div v-if="post.errors.length > 0" class="flex">
<ic:baseline-error class="text-xl mr-2 text-fly-600 dark:text-fly-500" /> {{ post.errors[0].message }}
</div>
</div>
</div>
</template>

View File

@@ -15,6 +15,7 @@ export const usePostStore = defineStore('post', () => {
async function fetchPosts() {
postList.value = []
errors.value = []
loading.value = true
const result = await fetch('https://api.flycro.me/items/Post')
if (!result.ok) errors.value.push({ message: 'Failed to fetch posts' })
@@ -73,6 +74,7 @@ export const usePostStore = defineStore('post', () => {
initialLoad,
postList,
currentPost,
errors,
}
})