Firestore always make 3 api calls with one taking 60 secondes

孤街醉人 提交于 2021-02-08 06:58:20

问题


Each time I'm making a request using the Firestore library, there are 3 API calls made. One of them is taking to 60 seconds every time. I receive the data after some milliseconds, but in the network tab, I see a pending call that seems to be doing nothing.

Here's my code

import "firebase/firestore";
import firebase from "firebase/app";

const getData = () => {
  firebase
    .firestore()
    .collection("myCollection")
    .get();
}

Each time I call getData(), 3 API calls are made. Here's the network tab:

The request URL of the second call is: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects/my-project/databases/(default)

How can I avoid the 60s call?


回答1:


To avoid the 60s calls, I ended up calling the REST API directly without using the client library. Here's the documentation to follow to be able to make a request: Use the Cloud Firestore REST API and Cloud Firestore API



来源:https://stackoverflow.com/questions/55227974/firestore-always-make-3-api-calls-with-one-taking-60-secondes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!