Back

[SOLVED] [AppwriteException: Missing required parameter: "email"]

  • 0
  • Android
  • Accounts
  • Web
  • Users
Ahmed
20 May, 2023, 09:45

i am creating login and signup pages i've successfully signed up but during login facing some error LOG [AppwriteException: Missing required parameter: "email"]

TL;DR
The issue is with the login component. You need to use the spread operator when updating the state like you did in the signup component. Currently, the values in the state are getting overwritten, causing the error. In the login component, update the `setUser` function calls like this: ``` setUser({ ...user, password: value, }); ``` By doing this, the state values will not be overwritten and the error will be resolved. Code example: ``` <TextInput placeholder="Email" autoCapitalize="none" onChangeText={value => { setUser({ ...user,
Ahmed
20 May, 2023, 09:50

@D5 please help me

safwan
20 May, 2023, 10:15

can you show your code for the signup component?

Ahmed
20 May, 2023, 10:17

import React, {useState} from 'react'; import {View, TextInput, Button, Alert, SafeAreaView} from 'react-native'; import account from '../config'; import {v4 as uuidv4} from 'uuid'; import 'react-native-get-random-values';

const Signup = ({navigation}) => { const [user, setUser] = useState({ email: '', password: '', name: '', });

const handleSignup = async () => { const emailRegex = /^[^\s@]+@[^\s@]+[^\s@]+$/; console.log('password is ', user.password) if (!emailRegex.test(user.email)) { console.log('Invalid email address:', user.email); } else if (user.password.length < 8) { console.log('Invalid password: Password must be at least 8 characters'); return; } else { const promise = account.create( uuidv4(), user.email, user.password, user.name, ); promise.then( function(response){ console.log(response); navigation.navigate('LoginScreen') }, function(error){ console.log(error) } ) } console.log('User email:', user.email); console.log('User password:', user.password); console.log('User name:', user.name); };

Ahmed
20 May, 2023, 10:17

return ( <SafeAreaView> <View> <TextInput placeholder="Email" autoCapitalize="none" onChangeText={value => { setUser({ ...user, email: value, }); }} /> <TextInput placeholder="Password" onChangeText={value => { setUser({ ...user, password: value, }); }} secureTextEntry /> <TextInput placeholder="Name" onChangeText={value => { setUser({ ...user, name: value, }); }} />

TypeScript
    <Button title="Signup" onPress={handleSignup} />
  </View>
</SafeAreaView>

); };

export default Signup;

safwan
20 May, 2023, 10:18

@Ahmed please use 3 ` at the start and end of the code to format it. Makes it easier to read

Ahmed
20 May, 2023, 10:19
Ahmed
20 May, 2023, 10:20
safwan
20 May, 2023, 10:21

Yep as I thought. In your signup component, you're doing setUser({...user, password: value}); which is correct.

In your login component, you're only doing setUser({password: value}). So what's happening is, the values that are already stored in the state are getting overwritten.

safwan
20 May, 2023, 10:21

Use the spread operator, and it should work fine.

Ahmed
20 May, 2023, 10:22

ohh i got it

Ahmed
20 May, 2023, 10:23

solved my error

Ahmed
20 May, 2023, 10:23

great

Ahmed
20 May, 2023, 10:23

yes it worked

D5
20 May, 2023, 10:31

[SOLVED] [AppwriteException: Missing required parameter: "email"]

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more