Fixing response when getting rsvps to marshal JSON

This commit is contained in:
collin 2025-08-10 15:40:20 +02:00
parent 7de0aa174d
commit dcd480b043
No known key found for this signature in database

View file

@ -3,6 +3,7 @@ package main
import ( import (
"database/sql" "database/sql"
"encoding/base64" "encoding/base64"
"encoding/json"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
@ -55,8 +56,15 @@ func (h *Handler) getRsvps(w http.ResponseWriter, r *http.Request) {
return return
} }
marshalledRsvps, err := json.Marshal(rsvps)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "%s", err.Error())
return
}
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "%#v", rsvps) fmt.Fprintf(w, "%s", marshalledRsvps)
} }
func (h *Handler) createRsvp(w http.ResponseWriter, r *http.Request) { func (h *Handler) createRsvp(w http.ResponseWriter, r *http.Request) {