Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.2 KB

youtubes.js.pagination.all.md

File metadata and controls

42 lines (27 loc) · 1.2 KB

Home > youtubes.js > Pagination > all

Pagination.all() method

Fetches all pages data.

Signature:

all(): Promise<Result<T[], YouTubesJsErrors>>;

Returns:

Promise<Result<T[], YouTubesJsErrors>>

All pages data in an array. If several items are in a page, this method will return a 2D array. Use flat() to convert it to a 1D array.

Remarks

  • This method may consume unnecessary quotas, so be careful when using it in actual applications. - We strongly recommend fetching the next page based on user actions (e.g., scrolling).

Example

import { ApiClient, StaticOAuthProvider } from "youtubes.js";

const oauth = new StaticOAuthProvider({
 accessToken: "ACCESS_TOKEN",
});
const client = new ApiClient({ oauth });

const playlists = await client.playlists.getMine();
if (playlists.isErr()) {
    // Handle the error
   return;
}
const allPlaylists = (await playlists.all()).flat();