React Native:firebase登录可能未处理的承诺拒绝

时间:2018-03-22 03:33:44

标签: firebase react-native promise

我收到以下错误:可能未处理的承诺拒绝(id:0:成功登录我的firebase时网络请求失败, 这是承诺代码,我不知道这里有什么问题,任何想法?

   firebase.auth().signInWithEmailAndPassword(email, password)
            .then(() => { this.setState({ error: '', loading: false }); })
            .catch(() => {
                //Login was not successful, let's create a new account
                firebase.auth().createUserWithEmailAndPassword(email, password)




                    .then((response) => { this.setState({ error: '', loading: false })


fetch('https://mywebsite.com/endpoint/', {
  method: 'POST',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    firebase_id: response.uid ,
    firebase_token: 'response.token',
  }),
}) .then((response) => response.json())
.then((responseJson) => {
  return responseJson.movies;
})
.catch((error) => {
  console.error(error);
});

; })
                        .catch(() => {
                            this.setState({ error: 'Authentication failed.', loading: false });
                        });
                });

0 个答案:

没有答案