Giter Club home page Giter Club logo

axios-cancel's People

Contributors

dependabot[bot] avatar thaerlabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

axios-cancel's Issues

Potentially unhandled rejection [15] Error

When using axios-cancel and http response is 401 error (I think the same for all 4xx) "Potentially unhandled rejection [15] Error" occurs.

The problem that error does not get to the .catch():

return axios({
                url: prepareURL(url),
                method: 'post',
                headers: prepareAuthHeader(),
                data: params,
                requestId: requestId
            }).then((response) => response.data)
            .catch(function(thrown){  // 400 Error is not going here
                if (axios.isCancel(thrown)){
                    console.log('Request canceled', thrown.message);
                } else{
                    when.reject(thrown);
                }
            });

axio-cancel debug log:
adding request 1
index.js:1 adding request '1484560946801' xhr.js:175 POST http://..../... 401 (Unauthorized) dispatchXhrRequest @ xhr.js:175 xhrAdapter @ xhr.js:12 dispatchRequest @ dispatchRequest.js:52 unhandledRejection.js:23 Potentially unhandled rejection [1] Error: Request failed with status code 401 at createError (http://..../index-1484560715206.js:24790:16) at settle (http://..../index-1484560715206.js:24762:13) at XMLHttpRequest.handleLoad (http://..../index-1484560715206.js:24638:8) (anonymous) @ unhandledRejection.js:23 report @ unhandledRejection.js:50 flush @ unhandledRejection.js:72
index.js:1 removing request 1

P.S. I'm new to javascript so maybe it could be my mistake, I could add more context if needed.

TypeScript

I was wondering how you would add typings for this, since Axios comes with its own. I can't think how to override the axios object and add the properties like requestId.

axios.isCancel() doesn't return true when cancellation is thrown

Axios#isCancel implementation ==> https://github.com/axios/axios/blob/master/lib/cancel/isCancel.js

Thrown cancellation error object when using the library with axios:
screen shot 2019-01-03 at 4 32 49 pm

Notice how the implementation doesn't account for the axios-cancel thrown error object format.

Example used in documentation:

// 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)) { /// DOESN't WORK
      console.log('request cancelled');
    } else {
      console.log('some other reason');
    }
  });

axios.cancel(requestId);

Receiving Error while request cancellation

While cancellation of request Nuxtjs throws error as below:

cancelRequest(requestId) from RequestManager.addRequest. Found duplicate pending request.

Any help for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.