I have the following asynchronous submitNewPatient function which is throwing @typescript-eslint/no-misused-promises error message from elint. Is it possible to adjust the function such that it removes this error?
const submitNewPatient = async (values: PatientFormValues) => {
try {
const { data: newPatient } = await axios.post<Patient>(
`${apiBaseUrl}/patients`,
values
);
dispatch({ type: "ADD_PATIENT", payload: newPatient });
closeModal();
} catch (e: unknown) {
if (axios.isAxiosError(e)) {
console.error(e?.response?.data || "Unrecognized axios error");
setError(
String(e?.response?.data?.error) || "Unrecognized axios error"
);
} else {
console.error("Unknown …Run Code Online (Sandbox Code Playgroud) typescript reactjs asynchronous-javascript axios react-functional-component