const apiCallingFunction = async (data: any) =\> {
try {
let response = await axiosPost("/api", { ...data });
return response;
} catch (err: any) {
return err.response;
}
};
我想从 catch 块中删除任何内容。
import { AxiosError } from "axios";
const apiCallingFunction = async (data: any) => {
try {
let response = await axiosPost("/api", { ...data });
return response;
} catch (err: unknown) {
return (err as AxiosError).response;
}
};
Axios 有内置的错误类型,称为 AxiosError