Skip to content Skip to sidebar Skip to footer

How To Get A Single Document Data In A Firebase Firestore (without Promises)

im trying to get the data of a single document and save it to a variable for use it later in another logic operation. The firestore documentation show hot to do this only with prom

Solution 1:

As Jaromanda X commented: you're best of accepting the asynchronous nature of Firebase and most of the modern web. The sooner you get to grips with the programming patterns, the sooner you can get back to being productive in this paradigm.

I find it most helpful to reframe problems. Instead of "Load a document, then do something with it" I frame it as "First start loading a document. Once the document has loaded, do something with it".

In practice that means that you move your code that needs the document into the completion handler where you now have the logging statements.

Post a Comment for "How To Get A Single Document Data In A Firebase Firestore (without Promises)"