Added full Article creation pathway

This commit is contained in:
Florian Sylvain
2023-01-07 00:00:40 +01:00
parent 322c77549c
commit 4552ca8b1b
2 changed files with 55 additions and 7 deletions
+12
View File
@@ -21,4 +21,16 @@ export async function getArticle(id: string) : Promise<Article> {
.catch(error => {
console.error(error)
})
}
export async function postArticle(article: Article) : Promise<object> {
return await fetch(`${baseURL}/articles/${article.idName}`, {
method: 'POST',
headers: { "Authorization": `Bearer ${useAuthStore().token}` },
body: JSON.stringify(article)
})
.then(result => result.json())
.catch(error => {
console.error(error)
})
}