Fixing response when getting rsvps to marshal JSON
This commit is contained in:
parent
7de0aa174d
commit
dcd480b043
1 changed files with 9 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"database/sql"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
|
@ -55,8 +56,15 @@ func (h *Handler) getRsvps(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
marshalledRsvps, err := json.Marshal(rsvps)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprintf(w, "%s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, "%#v", rsvps)
|
||||
fmt.Fprintf(w, "%s", marshalledRsvps)
|
||||
}
|
||||
|
||||
func (h *Handler) createRsvp(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue