sdk-for-react-native icon indicating copy to clipboard operation
sdk-for-react-native copied to clipboard

[AppwriteException: Invalid `email` param: Value must be a valid email address]

Open Suvrajit69 opened this issue 1 year ago • 3 comments

👟 Reproduction steps

I just simply trying to register user based on email and password. This function is responsible for createUser.

export async function createUser(email, password, userName) {
  try {

    const newAccount = await account.create(
      ID.unique(),
      email,
      password,
      userName
    );
    // .catch((error) => console.log(error));

    console.log(newAccount);
    if (!newAccount) throw Error;

    const avatarUrl = avatar.getInitials(userName);

    await signIn(email, password);

    const newUser = await databases.createDocument(
      appwriteConfig.databaseId,
      appwriteConfig.userCollectionId,
      ID.unique(),
      {
        accountId: newAccount.$id,
        email: email,
        userName: userName,
        avatar: avatarUrl,
      }
    );
    return newUser;
  } catch (error) {
    console.log(error);
    throw new Error(error);
  }
}

👍 Expected behavior

It should register user but gives error

👎 Actual Behavior

[AppwriteException: Invalid email param: Value must be a valid email address]

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Suvrajit69 avatar Apr 28 '24 18:04 Suvrajit69

@Suvrajit69, thanks for creating this issue! 🙏🏼 Would you please log email before it's passed into account.create() or share the payload of the request?

stnguyen90 avatar May 15 '24 00:05 stnguyen90

I got the same issue for this code as well. Can someone help?

Krijestorac avatar May 16 '24 19:05 Krijestorac

If appwrite aren't interested in building a stable service maybe you all should throw the project into the bin and focus on writing html templates. because why have I been having [AppwriteException: Network request failed] thrown at my face all over development for the past 3 days now?

KyuubiTila avatar May 17 '24 08:05 KyuubiTila

@stnguyen90 I solved the error. Actually every time when I write my email in my phone, on the keyboard there is auto suggestion apperas showing my email. So I click on it and email form auto filled. But there is a empty space at the end of the email. That is why appwrite says invalid email. I solved the error using .trim(" ") method in my code. But the .trim method should be inside of appwrite code. I can solve this issue if you can help me. Thank you.

Suvrajit69 avatar May 29 '24 13:05 Suvrajit69