Last active
September 26, 2020 18:47
-
-
Save gordcurrie/f82c7d6131392f47be401bd79e814afa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| goshopify "github.com/bold-commerce/go-shopify/v3" | |
| ) | |
| func main() { | |
| client := goshopify.NewClient(goshopify.App{}, "SHOP_NAME", "API_TOKEN", goshopify.WithVersion("2020-07")) | |
| _, page, err := client.Product.ListWithPagination(nil) | |
| if err != nil { | |
| fmt.Printf("Error: %s", err.Error()) | |
| } | |
| // fmt.Printf("%+v", c) | |
| fmt.Printf("%+v", page) | |
| _, page, err = client.Product.ListWithPagination(page.NextPageOptions) | |
| if err != nil { | |
| fmt.Printf("Error: %s", err.Error()) | |
| } | |
| // fmt.Printf("%+v", c) | |
| fmt.Printf("%+v", page) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calling the
ListWithPaginationfunction will return a slice of entities, product entities in this case, as well as a pointer to a Pagination struct, and an error. The NextPageOptions field from the Pagination struct can be passed to the next call to ListWithPagination to fetch the next page. The PreviousPageOptions field could be passed return the previous page.go-shopify leverages the
Linkheader to populate the Pagination struct, and passes those options via request params.See: