MellKam / soundify

🎧 Lightweight integration with the Spotify Web API for modern Javascript runtimes
https://npmjs.com/@soundify/web-api
MIT License
25 stars 3 forks source link

Automatic pagination #35

Closed MellKam closed 8 months ago

MellKam commented 1 year ago

Paginator will create request for every 20 tracks.

const playlistTracks = new Paginator((opts) =>
  getPlaylistTracks(client, "6LPdVFowaGmmHu3nb20Mg3", opts)
);

for await (const track of playlistTracks) {
  console.log(track);
}

You can change the chunk size by setting limit in second argument.

const playlistTracks = new Paginator(
  (opts) => getPlaylistTracks(client, "6LPdVFowaGmmHu3nb20Mg3", opts),
  { limit: 50 }
);