Home > youtubes.js > Pagination > all
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.
- 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).
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();