chore: moved exampled to frontend

This commit is contained in:
Felix Dubrownik
2023-03-03 14:11:13 +01:00
parent 541f94131a
commit b9fa81f76b
134 changed files with 22 additions and 40368 deletions

View File

@ -0,0 +1,56 @@
export interface Todo {
todoID?: string;
description: string;
checked: boolean;
}
export type Todos = Todo[];
export class TodoClient {
api: string;
constructor(api: string) {
this.api = api;
}
addTodo(todo: Todo) {
return fetch(`${this.api}/todo`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(todo),
});
}
listTodos() {
return fetch(`${this.api}/todo`, {
credentials: "include",
});
}
patchTodo(id: string, checked: boolean) {
return fetch(`${this.api}/todo/${id}`, {
method: "PATCH",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({checked}),
});
}
deleteTodo(id: string) {
return fetch(`${this.api}/todo/${id}`, {
method: "DELETE",
credentials: "include",
});
}
logout() {
return fetch(`${this.api}/logout`, {
credentials: "include",
});
}
}