export async function createResource<T>(
  endpoint: string,
  data: T,
): Promise<Response> {
  return fetch(endpoint, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(data),
  });
}

export async function updateResource<T>(
  endpoint: string,
  data: T,
): Promise<Response> {
  return fetch(endpoint, {
    method: "PUT", // or 'PATCH'
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(data),
  });
}

export async function fetchData<T>(endpoint: string, data: T) {
  const res = await fetch("http://localhost:8080/api/" + endpoint);
  data = await res.json();
}
