I know this is probably really simple – but I’m horrendous at JavaScript and can’t figure this out. Have been looking through other StackOverflow posts for a good hour and all “solutions” don’t seem to work.
I have the below function – which returns what’s shown in the image – but i’m not sure how to convert this into a json object that I can actually work with on the frontend.
Anyone know how to modify this in order to accomplish that?
getTools = ({id}) => {
let ref = this.write.collection('tools').doc(id)
let results = []
ref.onSnapshot(snapshot => {
const id = snapshot.id
const data = snapshot.data()
results.push({...data, id})
});
return results
}