diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go index db382e3..528cda8 100644 --- a/packages/pagination/pagination.go +++ b/packages/pagination/pagination.go @@ -43,6 +43,9 @@ func (r *Page[T]) UnmarshalJSON(data []byte) error { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *Page[T]) GetNextPage() (res *Page[T], err error) { + if len(r.Data) == 0 { + return nil, nil + } // This page represents a response that isn't actually paginated at the API level // so there will never be a next page. cfg := (*requestconfig.RequestConfig)(nil) @@ -137,6 +140,10 @@ func (r *CursorPage[T]) UnmarshalJSON(data []byte) error { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *CursorPage[T]) GetNextPage() (res *CursorPage[T], err error) { + if len(r.Data) == 0 { + return nil, nil + } + if r.JSON.HasMore.Valid() && r.HasMore == false { return nil, nil }