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-featureGroups network-related assertions under 'NetworkRequests' feature
fs-assertUnique identifier for the API request (api-load-posts)
fs-triggerEvent that triggers the network request (click)
fs-assert-updatedValidates that the results container is updated with new content
fs-assert-response-statusValidates that the API returns the expected HTTP status code
fs-assert-timeoutSets maximum time (in ms) to wait for the API response