Product View aufgebaut
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import ky from 'ky'
|
||||
import type { Product } from '../../data/product'
|
||||
|
||||
export const getProducts = async (): Promise<Product[]> => {
|
||||
return ky.get(`http://localhost:8088/products`).json<Product[]>()
|
||||
}
|
||||
|
||||
export const getProductById = async (id: number): Promise<Product> => {
|
||||
return ky.get(`http://localhost:8088/product/${id}`).json<Product>()
|
||||
}
|
||||
|
||||
export const createProduct = async (id: string): Promise<Product> => {
|
||||
return ky.post(`http://localhost:8088/product`, { json: { id } }).json<Product>()
|
||||
}
|
||||
|
||||
export const updateProduct = async (product: Product): Promise<void> => {
|
||||
await ky.put(`http://localhost:8088/product`, { json: product })
|
||||
}
|
||||
|
||||
export const deleteProduct = async (id: number): Promise<void> => {
|
||||
await ky.delete(`http://localhost:8088/product/${id}`)
|
||||
}
|
||||
|
||||
export const getProductsByProductGroupId = async (productGroupId: number): Promise<Product[]> => {
|
||||
return ky.get(`http://localhost:8088/products/productGroup/${productGroupId}`).json<Product[]>()
|
||||
}
|
||||
Reference in New Issue
Block a user