mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
update axioserror
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { AxiosError } from 'axios';
|
||||
|
||||
export const extractErrorMessage = (error: AxiosError, defaultMessage: string) =>
|
||||
(error.response && error.response.data ? error.response.data.message : error.message) || defaultMessage;
|
||||
export const extractErrorMessage = (error: unknown, defaultMessage: string) => {
|
||||
if (error instanceof AxiosError) {
|
||||
return error.response && error.response.data && error?.response?.data?.message;
|
||||
} else if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
return defaultMessage;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user