React Native:await 是一个保留字
React Native: await is a reserved word
我试图保存我的用户已登录的事实,然后在他的管理页面上重定向他,但是当我使用 await 时,我得到了这个错误:
await is a reserved word (101)
另一件事,一旦我的用户注册,我想将他发送到一个新页面,而不是 "slide page" 我们可以通过右上角的箭头返回的页面。
我该怎么做?
这是我的代码:
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) => {
...
})
我试图保存我的用户已登录的事实,然后在他的管理页面上重定向他,但是当我使用 await 时,我得到了这个错误:
await is a reserved word (101)
另一件事,一旦我的用户注册,我想将他发送到一个新页面,而不是 "slide page" 我们可以通过右上角的箭头返回的页面。 我该怎么做?
这是我的代码:
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) => {
...
})