Files
tout-doux/resources/ts/api/tasks.ts
T
klemek 3edc076834
TS Lint / ESLint (push) Successful in 45s
Python Lint CI / ruff (push) Successful in 56s
Python Lint CI / ruff-format-check (push) Successful in 57s
Python Lint CI / ty (push) Successful in 1m4s
TS Lint / Oxlint (push) Successful in 6m39s
TS Lint / TypeScript (push) Successful in 6m31s
feat: typescript requests
2026-07-03 20:01:40 +02:00

38 lines
1.1 KiB
TypeScript

import type { RawTask, TaskCreateData, TaskUpdateData } from "@/types";
export async function getTasks(list: string): Promise<RawTask[]> {
const response = await fetch(`/api/lists/${list}/tasks`);
return await response.json();
}
export async function createTask(
list: string,
data: TaskCreateData,
): Promise<RawTask> {
const response = await fetch(`/api/lists/${list}/tasks`, {
method: "POST",
body: JSON.stringify({ data }),
headers: { "Content-Type": "application/json" },
});
return await response.json();
}
export async function updateTask(
list: string,
taskId: string,
data: TaskUpdateData,
): Promise<RawTask> {
const response = await fetch(`/api/lists/${list}/tasks/${taskId}`, {
method: "PUT",
body: JSON.stringify({ data }),
headers: { "Content-Type": "application/json" },
});
return await response.json();
}
export async function deleteTask(list: string, taskId: string): Promise<void> {
await fetch(`/api/lists/${list}/tasks/${taskId}`, {
method: "DELETE",
});
}