mirror of
https://github.com/Floriansylvain/snippets-manager-front.git
synced 2026-08-20 03:53:38 +02:00
feat: category creation
This commit is contained in:
@@ -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 }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user