I have a real-time firebase database with a structure like this:
-- places -- user1 uid -- name: -- latitude: -- longitude: -- user2 uid -- name: -- latitude: -- longitude: When fetching the data from firebase, I wanted to store it like this
-- user1 name -- latitude -- longitude -- user2 name -- latitude -- longitude Currently I have this code structure which loops through the data, but I am stuck on getting each data and store it as shown above.
constructor(props) { super(props); this.state = { places: [] }; } componentDidMount() { const ref = firebase.database().ref('places/'); ref.once('value', (snapshot) => { snapshot.forEach(snapshotchild => { snapshotchild.forEach(data => { }) }) }); }
console.log(data);