I have used Google Script to send data from Google sheet to firebase realtime database. Here I am trying to retrieve those data in json form. My real time databse looks like: [![enter image description here][1]][1] my service.ts
getRealData():Observable<any>{
return this.afs.collection('draft-memorial-default-rtdb')
.snapshotChanges().pipe(
map(item => {
return item.map(value => {
const ref = value.payload.doc.data();
console.log(ref);
return {
ref
};
});
})
);
}
Component:
ngOnInit() {
this.auth.getRealData().subscribe(res=>console.log(res));
}
I have done with other database but with realtime database how do we retrieve data if the data are stored from google sheet using google script? [1]: https://i.stack.imgur.com/D2Kfv.png
I found the solution : service.ts
getAll(): AngularFireList<any> {
return this.tutorialsRef;
}
component
ngOnInit() {
this.getRealData();
}
getRealData(): void {
this.auth.getAll().snapshotChanges().pipe(
map(changes =>
changes.map(c =>
({ key: c.payload.key, ...c.payload.val() })
)
)
).subscribe(res => {
this.data = res;
console.log(res);
});
}
It return the key value with they payload.