add crud store/api service
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 7s
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 7s
This commit is contained in:
20
client/src/api/UsersApi.ts
Normal file
20
client/src/api/UsersApi.ts
Normal 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}`);
|
||||
Reference in New Issue
Block a user