From 461691c79936d297b61bb8418bbe1a346183a134 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 9 Dec 2025 17:30:11 +0000 Subject: [PATCH] changing returned values --- backend/handlers/handle_post.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/handlers/handle_post.go b/backend/handlers/handle_post.go index dab3de2..515fe80 100644 --- a/backend/handlers/handle_post.go +++ b/backend/handlers/handle_post.go @@ -16,7 +16,7 @@ type CreatePostInput struct { func (store *Store) GetPosts(ctx *gin.Context) { var posts []models.Post if err := store.DB.Find(&posts).Error; err != nil { - ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + ctx.JSON(http.StatusInternalServerError, err.Error()) return } ctx.JSON(http.StatusOK, posts) @@ -26,7 +26,7 @@ func (store *Store) GetPost(ctx *gin.Context) { postID := ctx.Param("id") var post models.Post if err := store.DB.First(&post, postID).Error; err != nil { - ctx.JSON(http.StatusNotFound, gin.H{"error": err.Error()}) + ctx.JSON(http.StatusNotFound, err.Error()) return } @@ -36,7 +36,7 @@ func (store *Store) GetPost(ctx *gin.Context) { func (store *Store) CreatePost(ctx *gin.Context) { var input CreatePostInput if err := ctx.ShouldBindBodyWithJSON(&input); err != nil { - ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + ctx.JSON(http.StatusBadRequest, err.Error()) return } @@ -69,7 +69,7 @@ func (store *Store) UpdatePost(ctx *gin.Context) { postID := ctx.Param("id") var post models.Post if err := store.DB.First(&post, postID).Error; err != nil { - ctx.JSON(http.StatusNotFound, gin.H{"error": err.Error()}) + ctx.JSON(http.StatusNotFound, err.Error()) return }