Hi guys, I wanted to alert the user about the duplication error. How can I do it with moralis? It is showing me this error on the console in browser >
Uncaught (in promise) Error: Account already exists for this username.
at handleError (moralis.js:22042)
and this >
moralis.js:21909 POST https://imgvpmtqkpng.moralis.io:2053/server/classes/_User/7vCpYk1eiAZWbpUae4b5f2rN 400 (Bad Request)
Here is save profile function code >
saveUserInfo = async() => {
user.set('email', userEmail.value); //same changes have applied to the validate email function from user to functin
user.set('username', textUsrName.value);
if (userAvatarFile.files.length > 0) {
const avatar = new Moralis.File("avatarprfl.jpg", userAvatarFile.files[0]);
user.set('avatar', avatar);
}try {
user.save();
} catch (error) {
window.alert("Ижилхэн нэртэй байна.")
return openUsrInfo();
}
await user.save();
alert("Таны мэдээлэл амжилттай хадгалагдлаа");
console.log("123",error)
openUsrInfo();
}