fix some lint errors

This commit is contained in:
Romulus21
2024-02-19 08:29:56 +01:00
parent ebfc56eba3
commit d99b94be55
7 changed files with 39 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
import React, {useState} from "react"
import axios from "axios"
import axios, {AxiosError} from "axios"
import {cleanErrorsForm, displayFormErrors} from "../utilities/form"
const useAxiosTools = (isLoading = false) => {
@@ -12,11 +12,13 @@ const useAxiosTools = (isLoading = false) => {
const axiosPut = axios.put
const axiosDelete = axios.delete
const errorCatch = (error: any) => {
if (error.response && error.response.status === 422) {
displayFormErrors(error)
} else {
setError(error.response?.data.message || error.message)
const errorCatch = (error: Error|AxiosError|unknown) => {
if (axios.isAxiosError(error)) {
(error.response?.status === 422)
? displayFormErrors(error)
: setError(error.response?.data.message || error.message)
} else if (error instanceof Error) {
setError(error.message)
}
}