Skip to content

Commit

Permalink
Adjust axios error type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Oct 17, 2023
1 parent 2cf4f53 commit 282c802
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/src/components/Workflow/Import/FromFileOrUrl.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import axios, { type AxiosError } from "axios";
import axios from "axios";
import { computed, type Ref, ref } from "vue";
import { useRouter } from "vue-router/composables";
Expand Down Expand Up @@ -66,7 +66,10 @@ async function submit(ev: SubmitEvent) {
router.push(path);
} catch (error) {
const message = (error as AxiosError).response?.data && (error as AxiosError).response?.data.err_msg;
let message = null;
if (axios.isAxiosError(error)) {
message = error.response?.data?.err_msg;
}
errorMessage.value = message || "Import failed for an unknown reason.";
} finally {
loading.value = false;
Expand Down

0 comments on commit 282c802

Please sign in to comment.