const onSubmit = async (FormData) => {
FormData.bFlats = meters;
try {
let res = await axios({
method: 'post',
url: 'http://localhost:5000/api/v1/buildings',
data: FormData
});
console.log(res.data);
if (res.data.status === 'success') {
alert("Successfully Inserted");
reset();
}
} catch (error) {
console.log(error.response.data.message); // this is the main part. Use the response property from the error object
}
}