🚸 404 when post not found

This commit is contained in:
LittleSheep 2024-08-11 12:40:20 +08:00
parent ec53cf14fa
commit dfe6198b94

View File

@ -56,9 +56,15 @@
const route = useRoute() const route = useRoute()
const config = useRuntimeConfig() const config = useRuntimeConfig()
// TODO FIX 500 WHEN DATA NOT FOUND
const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${route.params.id}`) const { data: post } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/interactive/posts/${route.params.id}`)
if (!post.value) {
throw createError({
statusCode: 404,
statusMessage: 'Post Not Found'
})
}
const title = computed(() => post.value.body?.title ? `${post.value.body?.title} from ${post.value.author.nick}` : `Post from ${post.value.author.nick}`) const title = computed(() => post.value.body?.title ? `${post.value.body?.title} from ${post.value.author.nick}` : `Post from ${post.value.author.nick}`)
useHead({ useHead({