API Requests

Monitor network requests and response validation

Overview

This example demonstrates how Fault Sense validates API requests, response status codes, timeout handling, and content updates to ensure reliable data loading from external APIs.

Implementation

<!-- Load Posts Button -->
<button fs-feature="NetworkRequests"
        fs-assert="api-load-posts"
        fs-trigger="click"
        fs-assert-updated="#results"
        fs-assert-response-status="200"
        fs-assert-timeout="2600">
  Load Posts
</button>

<!-- Results Container -->
<div id="results">
  <!-- API response data will be displayed here -->
  <div class="post-item">
    <h4>Post Title</h4>
    <p>Post content...</p>
  </div>
</div>

Try it

Click the button to load posts from JSONPlaceholder API

Key Attributes

fs-feature

Groups network-related assertions under 'NetworkRequests' feature

fs-assert

Unique identifier for the API request (api-load-posts)

fs-trigger

Event that triggers the network request (click)

fs-assert-updated

Validates that the results container is updated with new content

fs-assert-response-status

Validates that the API returns the expected HTTP status code

fs-assert-timeout

Sets maximum time (in ms) to wait for the API response

Demo Event Collector

Note: Demo Mode

The Fault Sense events shown here are real assertions that have been resolved as you played with the interactive demos.

In production, events will be sent to a backend event collection endpoint that you configure, allowing results to be aggregated across all users.

No Fault Sense events detected yet.

Interact with the examples to see events logged here.