Fix panic in posts limit usage (#66)

* call model with limits in post

* fix bug in posts handler
This commit is contained in:
Asim Aslam
2021-02-05 12:57:29 +00:00
committed by GitHub
parent 470036abef
commit da0f4a9dba

View File

@@ -210,7 +210,7 @@ func (p *Posts) Index(ctx context.Context, req *proto.IndexRequest, rsp *proto.I
}
// iterate and add
for i := 0; i <= limit; i++ {
for i := 0; i < limit; i++ {
// strip the content
posts[i].Content = ""
rsp.Posts = append(rsp.Posts, posts[i])
@@ -256,7 +256,7 @@ func (p *Posts) Query(ctx context.Context, req *proto.QueryRequest, rsp *proto.Q
}
// iterate and add
for i := 0; i <= limit; i++ {
for i := 0; i < limit; i++ {
rsp.Posts = append(rsp.Posts, posts[i])
}