soundcloud-api-ts - v1.9.0
    Preparing search index...

    Function fetchAll

    • Collects all pages into a single flat array, with an optional maximum item limit.

      Type Parameters

      • T

      Parameters

      • firstPage: () => Promise<SoundCloudPaginatedResponse<T>>

        Function that fetches the first page of results

      • fetchNext: (url: string) => Promise<SoundCloudPaginatedResponse<T>>

        Function that fetches subsequent pages given a next_href URL

      • Optionaloptions: { maxItems?: number }

        Optional configuration

        • OptionalmaxItems?: number

          Maximum number of items to collect (defaults to all)

      Returns Promise<T[]>

      A promise that resolves to a flat array of all collected items

      import { fetchAll, searchTracks, scFetchUrl } from 'soundcloud-api-ts';

      const allTracks = await fetchAll(
      () => searchTracks(token, 'lofi'),
      (url) => scFetchUrl(url, token),
      { maxItems: 100 },
      );
      console.log(`Fetched ${allTracks.length} tracks`);