diff --git a/api/core/joke/setter.go b/api/core/joke/setter.go index c8ef51a..335b29c 100644 --- a/api/core/joke/setter.go +++ b/api/core/joke/setter.go @@ -2,6 +2,7 @@ package joke import ( "context" + "strconv" "jokes-bapak2-api/core/schema" "github.com/Masterminds/squirrel" @@ -47,7 +48,7 @@ func SetTotalJoke(db *pgxpool.Pool, ctx context.Context, memory *bigcache.BigCac return err } - var total = []byte{byte(len(data))} + var total = []byte(strconv.Itoa(len(data))) err = memory.Set("total", total) if err != nil { return err diff --git a/api/handler/joke/joke_total.go b/api/handler/joke/joke_total.go index a820134..298114f 100644 --- a/api/handler/joke/joke_total.go +++ b/api/handler/joke/joke_total.go @@ -3,7 +3,6 @@ package joke import ( "errors" core "jokes-bapak2-api/core/joke" - "strconv" "github.com/allegro/bigcache/v3" "github.com/gofiber/fiber/v2" @@ -38,6 +37,6 @@ func (d *Dependencies) TotalJokes(c *fiber.Ctx) error { return c. Status(fiber.StatusOK). JSON(ResponseJoke{ - Message: strconv.Itoa(int(total[0])), + Message: string(total), }) }