diff --git a/Backend/endpoints/time.go b/Backend/endpoints/time.go index 0e11a8e..4035e41 100644 --- a/Backend/endpoints/time.go +++ b/Backend/endpoints/time.go @@ -75,6 +75,12 @@ func getBookings(w http.ResponseWriter, r *http.Request) { http.Error(w, "Internal Server Error", http.StatusInternalServerError) return } + if r.Header.Get("Accept") == "application/json" { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(bookings) + return + } ctx := context.WithValue(r.Context(), "user", user) templates.TimePage(bookings).Render(ctx, w) }