Skip to content

Commit

Permalink
adds workaround for axios cancellation until its gets fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
InteractiveNinja committed Nov 7, 2023
1 parent 9be5fe9 commit c896d21
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/util/bookmark-util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios, { AxiosError } from "axios";
import { AxiosError, CanceledError } from "axios";
import { showToast, Toast } from "@raycast/api";

export function showErrorToast(error?: Error | AxiosError) {
if (!axios.isCancel(error)) {
export function showErrorToast(error: AxiosError) {
if (!isCancel(error)) {
showToast({
style: Toast.Style.Failure,
title: "Something went wrong",
Expand All @@ -22,3 +22,7 @@ export function showSuccessToast(message: string) {
export function validateUrl(url: string) {
return url.startsWith("http://") || url.startsWith("https://");
}

function isCancel(value: AxiosError | CanceledError<never>): boolean {
return value instanceof CanceledError;
}

0 comments on commit c896d21

Please sign in to comment.