A lightweight library (v0.2.2, last release Nov 2017, no active development) that simplifies cancelling Axios HTTP requests by providing a thin wrapper around Axios's built-in cancellation API. It allows assigning a requestId per request and cancelling individual requests via axios.cancel(id) or all pending requests via axios.cancelAll(). Unlike using raw CancelToken, axios-cancel manages cancellation tokens internally, reducing boilerplate. Works with Axios >=0.15.0. Current version is stable but unmaintained; consider using Axios's native cancellation with AbortController for newer Axios versions.
npm install axios-cancelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize axios-cancel, make a GET request with a requestId, and cancel it programmatically.
Migrate to AbortController or use Axios cancel token directly.
Pass a specific axios instance, e.g., const instance = axios.create(); axiosCancel(instance);
Ensure unique requestIds or handle cancellation in catch() properly.
Call axiosCancel(axios) at app initialization.
Add requestId to the request config object.
Use axios.isCancel() to differentiate cancellation from other errors.