From 2c97a5a38db2202af647d93742ed0846827707d7 Mon Sep 17 00:00:00 2001 From: Brian Pham Date: Tue, 2 Jul 2024 20:06:43 -0700 Subject: [PATCH] fix: added an empty view query params checker and setting it to 'all' --- app/handlers/apiv1/post.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/handlers/apiv1/post.go b/app/handlers/apiv1/post.go index 7d4f41d4f..9fb086be3 100644 --- a/app/handlers/apiv1/post.go +++ b/app/handlers/apiv1/post.go @@ -15,9 +15,13 @@ import ( // SearchPosts return existing posts based on search criteria func SearchPosts() web.HandlerFunc { return func(c *web.Context) error { + viewQueryParams := c.QueryParam("view") + if viewQueryParams == "" { + viewQueryParams = "all" // Set default value to "all" if not provided + } searchPosts := &query.SearchPosts{ Query: c.QueryParam("query"), - View: c.QueryParam("view"), + View: viewQueryParams, Limit: c.QueryParam("limit"), Tags: c.QueryParamAsArray("tags"), }