const apiCallingFunction = async (data: any) =\> {
try {
let response = await axiosPost("/api", { ...data });
return response;
} catch (err: any) {
return err.response;
}
};
I want to remove any from the catch block.
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 Has Inbuilt Type for error Known As AxiosError