Article edition now getting article from DB by ID

This commit is contained in:
Florian Sylvain
2023-01-06 23:28:06 +01:00
parent ea8468aa93
commit 322c77549c
3 changed files with 35 additions and 5 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useAuthStore } from "@/stores/AuthStore"
export interface Article {
idName: string,
date: number,
content: {
html: string
},
pageId: string,
online: boolean
}
const baseURL = `http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}`
export async function getArticle(id: string) : Promise<Article> {
return await fetch(`${baseURL}/articles/${id}`, {
method: 'GET',
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
})
.then(result => result.json())
.catch(error => {
console.error(error)
})
}