2017-09-18 66 views
1

我想保存我的用戶登錄,然後重定向了他的管理頁面上的事實保留字,但是當我用等待我得到這個錯誤:陣營母語:等待是

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); 
    }); 
} 

預先感謝您的幫助球員。

回答

4

當在函數中調用await它必須被標記爲async

this.state.passwordLogin).then(aysnc (user) => { 
... 
}) 
+0

感謝布魯諾:) –

相關問題