Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise error message in console on cancellation #1347

Closed
c0debreaker opened this issue Feb 8, 2018 · 3 comments
Closed

Promise error message in console on cancellation #1347

c0debreaker opened this issue Feb 8, 2018 · 3 comments

Comments

@c0debreaker
Copy link

I'm trying Axios' cancellation of network request. It's working great.

I have a question about return Promise.reject(error). When I cancel my http get request, I get Uncaught (in promise) in console in color red. Is this normal?

export function retrieveInformation() {
    if (cancel !== undefined) {
      cancel();
    }
    return axios.get('http://blah.blah.com', {
      cancelToken: new CancelToken(function executor(c) {
        cancel = c;
      })
    })
    .then(res => res)
    .catch(error => {
      return Promise.reject(error) // <----- When this code is present, I get the error above
    });
}```
@Khaledgarbaya
Copy link
Collaborator

That's because you are rejecting the promise and if you don't catch somewhere else the error will popup

@c0debreaker
Copy link
Author

Yup, I got it working last night. Thanks.

@volkanciloglu
Copy link

@c0debreaker Could you tell me how you solved the problem? I am having this problem.
the only difference from your code is that I use 'await'.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants