I am experiencing some weird behavior when trying to retrieve data from firebase, when I launch the app and run this function:
const _query = query(_collection, where("userid", "==", uniqueUserID))
const querySnapshot = await getDocs(_query)
querySnapshot.forEach((doc) => {
console.log(doc.data())
});
I am given this error:
Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to
the backend.
However, if I manually refresh the app and the useEffect that contains that function is ran again, it successfuly gets the data. This is pretty strange considering both functions are the exact same and get called whenever the view is loaded or refreshed. How do I fix this?
NOTE: I am using firebase 9.6.11 and expo
EDIT: After plenty of research I finally found something that has seemingly fixed the issue, when running the emulator you need to make sure that the API level is above 25, this fixed it in android, for iOS I can't verify. I don't know why this happens.