mirror of
https://github.com/Floriansylvain/snippets-manager-front.git
synced 2026-08-19 19:53:17 +02:00
21 lines
525 B
TypeScript
21 lines
525 B
TypeScript
import { useApi } from '@/composables/api'
|
|
import { defineStore } from 'pinia'
|
|
|
|
export const useCategoriesStore = defineStore('categories', () => {
|
|
const api = useApi()
|
|
|
|
const getCategories = async (): Promise<Response> => {
|
|
return await fetch(`${api.url}/category`, api.options)
|
|
}
|
|
|
|
const postCategory = async (name: string): Promise<Response> => {
|
|
return await fetch(`${api.url}/category`, {
|
|
...api.options,
|
|
method: 'POST',
|
|
body: JSON.stringify({ name })
|
|
})
|
|
}
|
|
|
|
return { getCategories, postCategory }
|
|
})
|