Odium
Odium

Reputation: 87

React Native Firestore - Get field values

I want to save my field values into a local array.
Example:
image
I will get ["84724302","60855802"] And by the way the field name is not 0 & 1.

When I'm trying to do it with documentSnapshot.data() it returns this result: [{"field_name": "84724302", "field_name": "60855802"}]
But I need to get this result: ["84724302","60855802"]

Upvotes: 0

Views: 195

Answers (1)

El Hassane Essadrati
El Hassane Essadrati

Reputation: 443

just convert the object that you are getting to an array

firestore.collection('collection').doc('123').onSnapshot(doc=>{
  const arr=Object.values(doc.data())
 console.log(arr) // ["84724302","60855802"]
//...
})

Upvotes: 1

Related Questions