Skip to content

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 removed this from the v0.20.0 milestone Aug 25, 2020
@JasonHK JasonHK requested a review from jasonsaayman November 3, 2020 06:57
@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 👍

This was referenced Mar 18, 2021
mbargiel pushed a commit to mbargiel/axios that referenced this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a typeguard for discriminating AxiosError type from Error type

6 participants