Add content creation
This commit is contained in:
37
src/views/contents/ContentList.vue
Normal file
37
src/views/contents/ContentList.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
|
||||
<div class="flex">
|
||||
<ContentCard v-for="content in contents"
|
||||
:content="content"
|
||||
class="m-2 bg-red w-full">
|
||||
</ContentCard>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import {useClient} from '@/plugins/api.js';
|
||||
import {defineProps, onBeforeMount, ref} from 'vue';
|
||||
import ContentCard from "./ContentCard.vue";
|
||||
|
||||
const props = defineProps({
|
||||
creatorId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
const client = useClient();
|
||||
const contents = ref();
|
||||
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
const response = await client.get(`/api/contents/user/${props.creatorId}`)
|
||||
contents.value = response.data
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch posts", error);
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user