I am trying to do a simple fetch of all people -- with pagination -- using the following example code, but I am getting a compiler error.
package main
import (
"fmt"
"log"
"os"
"github.com/WebexCommunity/webex-go-sdk/v2"
"github.com/WebexCommunity/webex-go-sdk/v2/people"
)
func main() {
accessToken := os.Getenv("WEBEX_ACCESS_TOKEN")
if accessToken == "" {
log.Fatal("WEBEX_ACCESS_TOKEN environment variable is required")
}
client, err := webex.NewClient(accessToken, nil)
if err != nil {
log.Fatalf("Error creating client: %v", err)
}
options := &people.ListOptions{}
page, err := client.People().List(options)
if err != nil {
log.Fatalf("Error listing people: %v", err)
}
for {
for _, person := range page.Items {
fmt.Printf("Person: %s (%s)\n", person.DisplayName, person.Emails[0])
}
if !page.HasNext {
break
}
page, err = page.Next()
if err != nil {
log.Fatalf("Error listing people: %v", err)
}
}
}
The compiler error is...
./main.go:38:15: cannot use page.Next() (value of type *webexsdk.Page) as *people.PeoplePage value in assignment
Am I doing something wrong?
I am trying to do a simple fetch of all people -- with pagination -- using the following example code, but I am getting a compiler error.
The compiler error is...
Am I doing something wrong?