http
.post("/user/createAccount", data)
.then((res) => {
console.log(res.data);
navigate("/user/login");
})
.catch(function (err) {
toast.error(`${err.response.data.message}`);
});
let user = await UserAccount.findOne({
where: { emailAccount: data.emailAccount },
where: { phoneNo: data.phoneNo },
});
if (user) {
res.status(400).json({ message: "Email or Phone Number already exists." });
return;
}
The error message is not showing on using toast and data is undefined.
I deleted the .data.message and the toast pop up works again, however when .data.message is added back, data is undefined
{ data: { message: 'error' } }on error?