From defacfd94cb764854609896dda865bd9a4ec9bb8 Mon Sep 17 00:00:00 2001 From: gfleury Date: Thu, 19 Mar 2020 19:02:06 -0300 Subject: [PATCH] Better checks on HasNextPage --- api_response.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api_response.go b/api_response.go index 58b3039..b295e7a 100644 --- a/api_response.go +++ b/api_response.go @@ -555,9 +555,12 @@ func NewRawAPIResponse(r *http.Response) (*APIResponse, error) { // HasNextPage returns if response is paged and has next page and where it does start func HasNextPage(response *APIResponse) (isLastPage bool, nextPageStart int) { - isLastPage = response.Values["isLastPage"].(bool) - if !isLastPage { - nextPageStart = int(response.Values["nextPageStart"].(float64)) + isLastPage, ok := response.Values["isLastPage"].(bool) + if ok && !isLastPage { + floatStart, ok := response.Values["nextPageStart"].(float64) + if ok { + nextPageStart = int(floatStart) + } } return !isLastPage, nextPageStart }