title: How to save resulted values from firestore into a variable and use it on various components and states in Vue
body: <p>I'm looking for a way to save the results received from a firestore collection and use it on a variable and reuse the save it to data() and reuse it.</p>
  
  <p>I'm unsure how to save the results from a async function into a variable.</p>
  
  <p>Please help me with this guys</p>
  
  <p>Here is my code.</p>
  
  <pre><code>    import firebase from "firebase";
  
  
  export default{
  
    data() {
      return {
        uid: firebase.auth().currentUser.uid,
        teamLead: ""
      };
    },
    created() {
      db.collection("users").onSnapshot(users =&gt; {
        users.docChanges().forEach(user =&gt; {
          if (this.uid == user.doc.id) {
            this.teamLead = user.doc.data().teamLead
          }
        });
      });
  
    console.log(this.teamLead)
  </code></pre>
  
  <p><strong>In this code</strong> I would like to have the value of teamLead saved into the data() function. How do I do that?</p>