From 54a16fab4af32dea951b206ed7f4c5b7eb832df3 Mon Sep 17 00:00:00 2001 From: Tueem Date: Mon, 25 May 2026 23:55:24 +0200 Subject: [PATCH] fix(get): answer with valid json array --- internal/routes/get.go | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/internal/routes/get.go b/internal/routes/get.go index f9badf1..86bbb9c 100644 --- a/internal/routes/get.go +++ b/internal/routes/get.go @@ -14,26 +14,17 @@ func Get(w http.ResponseWriter, r *http.Request) { http.Error(w, "Cannot fetch svgs from database", http.StatusInternalServerError) return } - /* - data, err := json.Marshal(svgs) + data, err := json.Marshal(svgs) - if err != nil { - http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError) - return - } + if err != nil { + http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError) + return + } - _, err = w.Write(data) + _, err = w.Write(data) - if err != nil { - http.Error(w, "Could not write data.", http.StatusInternalServerError) - return - } - */ - - w.Header().Add("Content-Type", "application/json") - enc := json.NewEncoder(w) - - for _, svg := range svgs { - enc.Encode(svg) + if err != nil { + http.Error(w, "Could not write data.", http.StatusInternalServerError) + return } }