add crud store/api service
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 7s

This commit is contained in:
2026-03-07 00:53:08 -06:00
parent 533571859f
commit 31225b51b2
9 changed files with 412 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
// services are kinda whatever, but in general its a good idea for all api calls to be within a service (at least thats how angular handles it)
// this user service will handle all to <-> from the server when handling user objects
// should be injected with the http client (I think its axios ?)
import axios from "axios";
import type {AxiosResponse } from "axios";
import type { User } from "../models/User.ts";
const API_URL: string = "/api/items";
export const getUsers = () => axios.get<User[]>(API_URL);
export const getUser = (id: number) => axios.get<User>(`${API_URL}/${id}`);
export const createUser = (data: User) => axios.post<User>(API_URL, data);
export const updateUser = (id: number, data: User) => axios.put<User>(`${API_URL}/${id}`, data);
export const deleteUser = (id: number) => axios.delete<User>(`${API_URL}/${id}`);