diff --git a/src/components/Employee/ManageEmployee.jsx b/src/components/Employee/ManageEmployee.jsx index b158694b..97b58d5b 100644 --- a/src/components/Employee/ManageEmployee.jsx +++ b/src/components/Employee/ManageEmployee.jsx @@ -194,7 +194,8 @@ const ManageEmployee = () => { navigation("/employees"); }) .catch((error) => { - showToast(error.message, "error"); + const message = error?.response?.data?.message || error?.message || "Error occured during api calling" + showToast(message, "error"); setLoading(false); }); }; diff --git a/src/components/Employee/ManageRole.jsx b/src/components/Employee/ManageRole.jsx index d24384c1..49794541 100644 --- a/src/components/Employee/ManageRole.jsx +++ b/src/components/Employee/ManageRole.jsx @@ -157,9 +157,9 @@ const ManageRole = ( {employeeId, onClosed} ) => reset(); onClosed(); }) - .catch((err) => { - console.error(err); - showToast(err.message, "error"); + .catch((error) => { + const message = error?.response?.data?.message || error?.message || "Error occured during api calling" + showToast(message, "error"); setIsLoading(false); }); };