I'm trying to save the fact that my user is logged-in and then redirect him on his administration page but when I use await I got this error:
await is a reserved word (101)
Another thing, once my user is registered I would like to send him to a new page, not a "slide page" where we can get back with the arrow on the top right-hand side. How can I do this?
This is my code:
login(){
firebase.auth().signInWithEmailAndPassword(this.state.emailLogin,
this.state.passwordLogin).then((user) => {
// Send the user to the next step
try {
await AsyncStorage.setItem('@MySuperStore:key', 'I like
to save it.');
} catch (error) {
// Error saving data
}
const { navigate } = this.props.navigation;
navigate('Admin');
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
});
}
Thanks in advance for your help guys.
When using await
in a function it must be marked as async
this.state.passwordLogin).then( aysnc (user) => {
...
})