Skip to content

Commit

Permalink
Fix #260 Pass empty array instead of null value if response is empty …
Browse files Browse the repository at this point in the history
…in v1 get data attribute endpoint
  • Loading branch information
albinpa authored and georgepadayatti committed Oct 16, 2023
1 parent 53dcb76 commit 8c4b2a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/v1/handler/organization_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,14 @@ func GetTemplates(w http.ResponseWriter, r *http.Request) {
common.HandleError(w, http.StatusInternalServerError, m, err)
return
}
templates := []org.Template{}

response, _ := json.Marshal(getTemplatesResp{OrgID: o.ID.Hex(), Templates: o.Templates})
// Check if o.Templates is not empty, assign it to templates
if len(o.Templates) > 0 {
templates = o.Templates
}

response, _ := json.Marshal(getTemplatesResp{OrgID: o.ID.Hex(), Templates: templates})
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON)
w.WriteHeader(http.StatusCreated)
w.Write(response)
Expand Down

0 comments on commit 8c4b2a2

Please sign in to comment.