axios-cancelable

1.0.0 • Public • Published

axios-cancelable

package version package downloads standard-readme compliant package license make a pull request

Utility for cancellation of requests when using axios

Table of Contents

About

Personalized and actively maintained fork of axios-cancel

Install

This project uses node and npm.

$ npm install axios-cancelable
# OR 
$ yarn add axios-cancelable

Usage

import axios from 'axios';
import axiosCancel from 'axios-cancelable';
 
axiosCancel(axios, {
  debug: false // default
});
 
...
 
// Single request cancellation
const requestId = 'my_sample_request';
const promise = axios.get(url, {
  requestId: requestId
})
  .then((res) => {
    console.log('resolved');
  }).catch((thrown) => {
    if (axios.isCancel(thrown)) {
      console.log('request cancelled');
    } else {
      console.log('some other reason');
    }
  });
 
axios.cancel(requestId);
// aborts the HTTP request and logs `request cancelled`

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i axios-cancelable

Weekly Downloads

47

Version

1.0.0

License

MIT

Unpacked Size

18.5 kB

Total Files

11

Last publish

Collaborators

  • tiaanduplessis