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

# Record and validate network requests

> Wait for a single request or record a stream of requests, then assert on their status and payloads in **JavaScript**.

Use network steps to verify your UI sends the right data to the backend, or that
the backend returns what you expect.

## Wait for a single request

1. Add a **Register request listener** step: provide a URL regex and a key (e.g.
   `CHECKOUT_REQUEST`).
2. Trigger the request (submit a form, click a button, etc.).
3. Add an **Await listener** step with the same key. Save the result to an
   environment variable (e.g. `RESPONSE`). The step fails if no matching request
   completes within the timeout.
4. Add a **JavaScript** step to validate:

   ```js theme={null}
   assert(env.RESPONSE.response.status === 200);
   assert(env.RESPONSE.response.body.orderId);
   ```

## Record multiple requests

1. Add a **Record requests** step: provide a URL regex and a key (e.g.
   `ANALYTICS_EVENTS`).
2. Trigger the requests (navigate, click, fill forms, etc.).
3. Add a **Get recorded requests** step with the same key. Save the array to an
   environment variable (e.g. `REQUESTS`).
4. Validate in a **JavaScript** step:

   ```js theme={null}
   assert(env.REQUESTS.length === 3);
   assert(env.REQUESTS.every((r) => r.response?.status === 200));
   ```

<Note>
  Requests that didn't complete before **Get recorded requests** ran are still
  included in the array, without a `response` field.
</Note>

## Related

* [Writing assertions](/core-concepts/writing-assertions)
* [Request mocking](/platforms/web/request-mocking)
