Skip to content

Instantly share code, notes, and snippets.

@LauraKokkarinen
Last active February 24, 2024 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LauraKokkarinen/d4e1cc3f897ae519a76eac782aec139d to your computer and use it in GitHub Desktop.
Save LauraKokkarinen/d4e1cc3f897ae519a76eac782aec139d to your computer and use it in GitHub Desktop.
microsoft-graph-paging.ts
private async page(url: string, objects: any[] = []): Promise<any> {
const response = await this.graphClient.api(url).get();
if (response.value === undefined) return response; // The result is a single object, no need for paging.
objects = objects.concat(response.value);
if (response["@odata.nextLink"] !== undefined) {
return await this.page(response["@odata.nextLink"], objects);
}
return objects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment