log(`All users: ${JSON.stringify(allUsers)}`);
</code></pre>
<p>And similarly for groups, showing the same pattern for different types of collections</p>
<pre><code class="language-TypeScript">import { graphfi, DefaultHeaders } from &quot;@pnp/graph&quot;;
import &quot;@pnp/graph/groups&quot;;

const graph = graphfi().using(DefaultHeaders());

const allGroups = [];
let groups = await graph.groups.paged();

allGroups.push(...groups.value);

while (groups.hasNext) {
  groups = await groups.next();
  allGroups