Article GET route now returns Array

This commit is contained in:
Florian Sylvain
2023-01-09 17:37:22 +01:00
parent c818e15aff
commit 71e305766c
6 changed files with 16 additions and 20 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ export interface Article {
const baseURL = `http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}`
export async function getArticle(id: string) : Promise<Article> {
export async function getArticles(id: string) : Promise<Array<Article>> {
return await fetch(`${baseURL}/articles/${id}`, {
method: 'GET',
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { getArticle, type Article } from '@/utils/database';
import { getArticles, type Article } from '@/utils/database';
import Editor from '@tinymce/tinymce-vue';
import { onMounted, ref, type Ref } from 'vue';
import { useRoute } from 'vue-router';
@@ -8,7 +8,8 @@ const article: Ref<Article | void> = ref()
const editorData: Ref<string> = ref('')
onMounted(async () => {
article.value = await getArticle(useRoute().params.articleID as string)
const articleFetch = await getArticles(useRoute().params.articleID as string)
article.value = articleFetch[0]
editorData.value = article.value.content.html
})