阵营母语:等待是
问题描述:
我想保存我的用户登录,然后重定向了他的管理页面上的事实保留字,但是当我用等待我得到这个错误:阵营母语:等待是
await is a reserved word (101)
另一件事,一旦我的用户注册,我想将他发送到一个新的页面,而不是一个“幻灯片页面”,我们可以用右上角的箭头返回。 我该怎么做?
这是我的代码:
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);
});
}
预先感谢您的帮助球员。
答
当在函数中调用await
它必须被标记为async
this.state.passwordLogin).then(aysnc (user) => {
...
})
感谢布鲁诺:) –