title: How to return value from firestore database?
body: <p>I am having a hard time returning a value from the firestore database.
  I am trying to return the 'amount' from the database.
  When setting the variable i am able to console.log the 'amount'. (see code)
  But when i try to return the value at the end of the function, it does not return anything.('amount' is not defined  no-undef)
  How can i return this value. Any help would be great. Please keep in mind that i am still quite new to this topic.</p>
  
  <pre><code>        import firebase from 'firebase/app';
          import 'firebase/firestore';
          import 'firebase/auth';
  
          export default function checkAmount() {
  
              let user = firebase.auth().currentUser;
  
              if (user) {
                  let userUID = user.uid
                  let docRef = firebase.firestore().collection("users").doc(userUID);
  
                  docRef.get().then((doc) =&gt; {
                      if (doc.exists) {
                              let amount = doc.data().amount;
                              if (amount &gt; 0){
                                  console.log(amount) /// This does work
                              }
                          } else {
                              console.log("No such document!");
                          }
                      }).catch(function(error) {
                          console.log("Error getting document:", error);
                      });
              }
  
              return amount /// This **does not** return anything . How do i return the amount?
          }
  </code></pre>