From dabcd7b75ab868f2b8f448ebeb9c87bc503ac1eb Mon Sep 17 00:00:00 2001 From: Jake Walker Date: Tue, 11 Jul 2023 22:21:49 +0100 Subject: [PATCH] Fix API URLs --- .gitignore | 3 ++- client/src/lib/api.ts | 4 ++-- main.go | 2 +- public/index.html | 17 ++++++++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8ec071f..0757a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -340,5 +340,6 @@ $RECYCLE.BIN/ schedule +public/ dist/ -data.db \ No newline at end of file +schedule.db \ No newline at end of file diff --git a/client/src/lib/api.ts b/client/src/lib/api.ts index 42edac6..d3e1d82 100644 --- a/client/src/lib/api.ts +++ b/client/src/lib/api.ts @@ -23,7 +23,7 @@ export async function getSchedule(): Promise { } export async function createScheduleItem(data: { name: string, duration: string, date: string }) { - const res = await fetch(API_URL, { + const res = await fetch(`${API_URL}/items`, { method: "POST", headers: { "Content-Type": "application/json" @@ -42,7 +42,7 @@ export async function createScheduleItem(data: { name: string, duration: string, } export async function deleteScheduleItem(id: number) { - const res = await fetch(`${API_URL}/${id}`, { + const res = await fetch(`${API_URL}/items/${id}`, { method: "DELETE" }); diff --git a/main.go b/main.go index cca4f81..f08a638 100644 --- a/main.go +++ b/main.go @@ -71,7 +71,7 @@ func dateRange(from time.Time, to time.Time) []time.Time { } func main() { - db, err := gorm.Open(sqlite.Open("data.db"), &gorm.Config{}) + db, err := gorm.Open(sqlite.Open("schedule.db"), &gorm.Config{}) if err != nil { log.Fatalf("failed to open database: %v", err) } diff --git a/public/index.html b/public/index.html index c57eff5..fbc52b8 100644 --- a/public/index.html +++ b/public/index.html @@ -1 +1,16 @@ -Hello World! \ No newline at end of file + + + + + + + + Schedule + + + + +
+ + +