Rank 2: Process
i am creating login and signup pages i've successfully signed up but during login facing some error LOG [AppwriteException: Missing required parameter: "email"]
Votes
0
Replies
14
Participants
Unknown
Messages
15
Rank 2: Process
i am creating login and signup pages i've successfully signed up but during login facing some error LOG [AppwriteException: Missing required parameter: "email"]
Rank 2: Process
@D5 please help me
can you show your code for the signup component?
Rank 2: Process
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);
};
Rank 2: Process
return (
<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,
});
}}
/>
<Button title="Signup" onPress={handleSignup} />
</View>
</SafeAreaView>
);
};
export default Signup;
@Ahmed please use 3 ` at the start and end of the code to format it. Makes it easier to read
Rank 2: Process
Rank 2: Process
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.
Use the spread operator, and it should work fine.
Rank 2: Process
ohh i got it
Rank 2: Process
solved my error
Rank 2: Process
great
Rank 2: Process
yes it worked
Moderator
[SOLVED] [AppwriteException: Missing required parameter: "email"]