I'm using firestore in my react native app.In some case I calling firestore to get all docs from specific collection and for some reason the array of data received in wrong format.
{"_data": {"clinicAddress": "1", "clinicName": "Macab", "description": "Nice doctor I think", "docs": [], "doctorName": "Caaw", "timestamp": 1652290939, "title": "Check my ears"}, "_exists": true, "_metadata": {"_metadata": [false, false]}, "_ref": {"_documentPath": {"_parts": [Array]}, "_firestore": {"_app": [FirebaseApp], "_config": [Object], "_customUrlOrRegion": undefined, "_nativeModule": [Object], "_referencePath": [FirestorePath], "_settings": [Object], "_transactionHandler": [FirestoreTransactionHandler]}}}
How can I get only the objects inside data?
Here is my interface:
export interface Appointment { clinicAddress: string; clinicName: string; description: string; docs: any[]; doctorName: string; timestamp: number; title: string;}
And this is the function to fetch the data:
export const fetchAppointments = (): Promise<any> => new Promise(async (resolve, reject) => { try { const data = await firestore().collection('users').doc(auth().currentUser?.uid).collection('appointments').get(); resolve(data.docs); } catch (e) { console.log(e); reject(e); } });