ERROR Error updating user profile: [AppwriteException: Missing required parameter: "password"]"
- 0
- React Native
Hi guys! I'm a junior react- native dev and I need some help updating data in appetite cloud, my problem is updating profile on parameter updatePassword and all the time I'm getting the same error ERROR Error updating user profile: [AppwriteException: Missing required parameter: "password"]" can you see anything wrong in here to cause the error? Thanks!: export const updateUserProfile = async (userId, newEmail, password, oldPassword, newUsername, newAvatarUrl) => { try { if (newEmail) { await account.updateEmail(newEmail); } if (password) { if(oldPassword){ await account.updatePassword(password, oldPassword);
} else{
await account.updatePassword(password);
}}
const updatedUser = await databases.updateDocument(
config.databaseId,
config.userCollectionId,
userId,
{
username: newUsername,
avatar: newAvatarUrl,
email: newEmail,
}
);
return updatedUser;
} catch (error) { console.error('Error updating user profile:', error); throw new Error(error.message); } };
And I'm calling this way : const handleSaveChanges = async () => { if (!newUsername) { Alert.alert('Username cannot be empty'); return; } if (password && !oldPassword) { Alert.alert('To change your password, please enter your current password.'); return; }
setLoading(true);
try { const updatedUser = await updateUserProfile( user.$id, newEmail, password, oldPassword, newUsername, newAvatar); setUser(updatedUser);
Alert.alert('Success', 'Profile updated successfully');
} catch (error) { Alert.alert('Error', error.message); } finally { setLoading(false); } };
To update an email you need to provide the current password for the user.
You should be getting type hints in your IDE that you're missing a param?
Recommended threads
- Custom domain for Google Auth
Hello! I connected my custom domain to my Appwrite project, but I can't get the Google login/consent screen to show my domain instead of the Appwrite domain. I...
- [SOLVED] Production down - createExecuti...
Hey, Since 1.9.6 rollout in fra (~17:00 UTC, 14 Aug), POST /v1/functions/{functionId}/executions returns a 400 whenever the body includes an empty headers ob...
- Quota not resetting
hi, im using appwrite's free tier plani hit my read limts last month and the billing cycle said it would reset on june 4th but that is today, the billing cycle ...