Skip to content

tiaanduplessis/axios-cancelable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛑 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

About

Utility for cancellation of requests when using axios

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published