zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.4k stars 294 forks source link

Next field not updating #261

Open michaelriri opened 5 months ago

michaelriri commented 5 months ago

Can someone help my identify what's wrong with this? I'm trying to page through all the search results, but the loop never breaks:

ctx := context.Background()
results, err := client.Search(ctx, "lofi", spotify.SearchTypeTrack|spotify.SearchTypeAlbum|spotify.SearchTypeArtist, spotify.Limit(50))
if err != nil {
    log.Fatal(err)
}
for {
    err = client.NextTrackResults(ctx, results)
    if err == spotify.ErrNoMorePages {
        break
    }
    if err != nil {
        log.Fatal(err)
    }
}

This loop runs infinitely where SearchResult.Tracks.Next stays locked at https://api.spotify.com/v1/search?query=lofi&type=track&offset=950&limit=50.

michaelriri commented 2 months ago

Am I doing something wrong here?