> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# withNetworkSettledWait

Executes a callback function and waits for network activity to settle before returning.

```typescript theme={null}
export declare function withNetworkSettledWait<T>(callback: (page: Page) => Promise<T>,
  options?: {
    page: Page;
    timeoutInMs?: number;
    maxInflightRequests?: number;
  }): Promise<T>;
```

## `withNetworkSettledWait` vs `waitForDomSettled`

* Use `withNetworkSettledWait` when watching **network requests** (API calls, form submissions, resource loading)
* Use [waitForDomSettled](https://intunedhq.com/docs/automation-sdks/intuned-sdk/typescript/helpers/functions/waitForDomSettled.md) when watching **DOM mutations** (elements added/removed/modified, loading spinners, dynamic content injection)

## Examples

```typescript Wrapper with Inline Function theme={null}
import { withNetworkSettledWait } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://sandbox.intuned.dev/infinite-scroll");

  // Execute action and wait for network to settle
  const result = await withNetworkSettledWait(
    async (page) => {
      // scroll to load more content
      await page.evaluate(() => {
        window.scrollTo(0, document.body.scrollHeight);
      });
      return "scrolled";
    },
    {
      page,
      timeoutInMs: 15000,
      maxInflightRequests: 0,
    }
  );
  console.log(result); // "scrolled"
  return result;
}
```

```typescript Click Link with Network Wait theme={null}
import { withNetworkSettledWait } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://sandbox.intuned.dev/");

  // Click Object Extractors link and wait for page to load
  await withNetworkSettledWait(
    async (page) => {
      await page.getByText("Object Extractors").click();
    },
    {
      page,
      timeoutInMs: 10000,
      maxInflightRequests: 0,
    }
  );
  // Object Extractors page loaded
  const title = await page.locator("div h2").innerText();
  return title;
}
```

## Arguments

**callback** `Function` *required*

The callback function to execute. Receives the page object as parameter

**options** `Object`

Configuration options for network monitoring

**properties**

**options.page** `Page` *required*

The Playwright page object to monitor for network activity

**options.timeoutInMs** `number`

Maximum time to wait in milliseconds before timing out. Defaults to 30000

**options.maxInflightRequests** `number`

Maximum number of pending requests to consider as "settled". Defaults to 0 (waits for all requests to complete)

## Returns: `Promise<T>`

Promise that resolves to the callback's return value after network settles


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.