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

Adding a type guard for AxiosError #2949

Merged
merged 13 commits into from Nov 3, 2020

Conversation

JasonHK
Copy link
Contributor

@JasonHK JasonHK commented May 6, 2020

This type guard allows TypeScript users to use the AxiosError interface without typecasting.

Usage

import axios, { isAxiosError } from "axios";

axios.get("/endpoint")
    .catch(
        (error) =>
        {
            if (isAxiosError(error)) { ... }
        });

Fix #1863

Copy link
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good lets add it onto v0.20

@jasonsaayman jasonsaayman added this to In progress in v0.20.0 via automation May 6, 2020
@jasonsaayman jasonsaayman added this to the v0.20.0 milestone May 6, 2020
@jasonsaayman jasonsaayman moved this from In progress to Reviewer approved in v0.20.0 Aug 25, 2020
@jasonsaayman jasonsaayman moved this from Reviewer approved to Done in v0.20.0 Aug 25, 2020
@jasonsaayman jasonsaayman removed this from the v0.20.0 milestone Aug 25, 2020
@jasonsaayman jasonsaayman added this to the v0.21.1 milestone Nov 3, 2020
Copy link
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and having tests is great 👍

@jasonsaayman jasonsaayman merged commit f472e5d into axios:master Nov 3, 2020
This was referenced Mar 18, 2021
mbargiel pushed a commit to mbargiel/axios that referenced this pull request Jan 27, 2022
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v0.20.0
  
Done
Development

Successfully merging this pull request may close these issues.

Add a typeguard for discriminating AxiosError type from Error type
6 participants