Skip to content

Conversation

@AKASHDHARDUBEY
Copy link
Contributor

This PR adds a comprehensive example demonstrating how to cancel HTTP requests using the AbortController API.

Changes

  • Added examples/abort-controller/index.html: A frontend example showing:
    • Single Request Cancellation: How to cancel a specific long-running request.
    • Search-as-you-type: A real-world pattern where previous pending requests are cancelled when the user keeps typing, preventing race conditions.
  • Added examples/abort-controller/server.js: A simple backend handler that simulates delayed responses to facilitate the cancellation demonstration.

Motivation

While Axios supports AbortController, the examples/ directory lacked a clear, practical demonstration of this feature. This example helps developers understand how to implement cancellation patterns correctly, which is crucial for performance and user experience in modern web applications.

How to Test

  1. Run the examples server:
    npm run examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant