feat: category creation

This commit is contained in:
Florian Sylvain
2024-10-10 22:26:54 +02:00
parent 81bc46ebfa
commit ec9bc1bb4b
7 changed files with 121 additions and 39 deletions
+10 -2
View File
@@ -4,9 +4,17 @@ import { defineStore } from 'pinia'
export const useCategoriesStore = defineStore('categories', () => {
const api = useApi()
const getCategories = async () => {
const getCategories = async (): Promise<Response> => {
return await fetch(`${api.url}/category`, api.options)
}
return { getCategories }
const postCategory = async (name: string): Promise<Response> => {
return await fetch(`${api.url}/category`, {
...api.options,
method: 'POST',
body: JSON.stringify({ name })
})
}
return { getCategories, postCategory }
})