Error handler service call


 const data = new FormData(;
    const query = new Moralis.Query("UserInfo");
    query.equalTo("userId", user);
    const result = await query.first({ useMasterKey: true });
    result.set("username", data.get("username").trim());
      (res) => {
        toast.success("Profile successfully updated!", options);
      (error) => {
        toast.error("Profile update unsuccessful! " + error.message, options);

If username is not unique in the before save trigger, I return an error and although the code enters the error section, it performs the save operation. What can i do to dont save if it returns error?

You could try to see if the user already exists with a query.

I don’t know why it will save when it returns an error