💻 Tech
If you’re using go-auth0 and listing resources, you might encounter a List method returning a struct with embedded List struct which provides the following structure:
management_request.go
type List struct {
Start int `json:"start"`
Limit int `json:"limit"`
Length int `json:"length"`
Total int `json:"total"`
Next string `json:"next"`
}
If so, you need to use what they call page-based pagination.
In the article above, they provided an example way to iterate the resource list using pagination:
for {
clients, err := m.Client.List(
context.TODO(),
management.Page(page),
management.PerPage(100),
)
if err != nil {
return err
}
// Accumulate here the results or check for a specific client.
// The `HasNext` helper func checks whether
// the API has informed us that there is
// more data to retrieve or not.
if !clients.HasNext() {
break
}
page++
}