RNFetchBlob阻止了Firebase / firestore调用本机响应

时间:2019-01-07 11:28:17

标签: javascript reactjs firebase react-native google-cloud-firestore

我有一个使用Firebase / firestore的React本机应用程序。为了上传图片,我使用“ react-native-fetch-blob”创建一个Blob。

我正在尝试从Firestore提取文档,但是我的应用程序被阻止并且没有从Firestore得到任何响应(不是catch / none =>仅通过代码传递)。

我可以做些什么来从Firestore获取文档吗?

下面是我的代码

import firebase from "../../../firebaseConfig";
import RNFetchBlob from "react-native-fetch-blob";

// Prepare Blob support
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
const Blob = RNFetchBlob.polyfill.Blob;
const fs = RNFetchBlob.fs;
window.Blob = Blob;
const originalXMLHttpRequest = window.XMLHttpRequest;
const originalBlob = window.Blob;

var firebaseUid = "";

componentDidMount = async () => {
firebaseUid = await firebase.auth().currentUser.uid;
this.getMyStory();
};

 getMyStory = async () => {
  window.XMLHttpRequest = originalXMLHttpRequest;
  window.Blob = originalBlob;
  var docRef = await firebase
   .firestore()
   .collection("demo")
   .doc(firebaseUid)
   .collection("ArrayDoc");
  docRef
  .get()
  .then(querySnapshot => {
    querySnapshot.forEach(doc => {
      console.log(doc.id, " => ", doc.data());
    });
  })
  .catch(error => {
    console.log("error", JSON.stringify(error));
  });
};

错误画面 enter image description here

0 个答案:

没有答案