@@ -42,14 +42,17 @@ func (api *api) projects(rw http.ResponseWriter, r *http.Request) {
42
42
projects , err := api .Database .GetProjectsByOrganizationIDs (r .Context (), organizationIDs )
43
43
if errors .Is (err , sql .ErrNoRows ) {
44
44
err = nil
45
- projects = []database.Project {}
46
45
}
47
46
if err != nil {
48
47
httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
49
48
Message : fmt .Sprintf ("get projects: %s" , err .Error ()),
50
49
})
51
50
return
52
51
}
52
+ // Don't return 'null'
53
+ if projects == nil {
54
+ projects = []database.Project {}
55
+ }
53
56
render .Status (r , http .StatusOK )
54
57
render .JSON (rw , r , projects )
55
58
}
@@ -60,14 +63,17 @@ func (api *api) projectsByOrganization(rw http.ResponseWriter, r *http.Request)
60
63
projects , err := api .Database .GetProjectsByOrganizationIDs (r .Context (), []string {organization .ID })
61
64
if errors .Is (err , sql .ErrNoRows ) {
62
65
err = nil
63
- projects = []database.Project {}
64
66
}
65
67
if err != nil {
66
68
httpapi .Write (rw , http .StatusInternalServerError , httpapi.Response {
67
69
Message : fmt .Sprintf ("get projects: %s" , err .Error ()),
68
70
})
69
71
return
70
72
}
73
+ // Don't return 'null'
74
+ if projects == nil {
75
+ projects = []database.Project {}
76
+ }
71
77
render .Status (r , http .StatusOK )
72
78
render .JSON (rw , r , projects )
73
79
}
0 commit comments