title: Using promises in firebase firestore update function in javascript
body: <p>I am trying to send the user to another page as soon as an update of the user's name has been completed. The problem is that I don't know when to call my location.replace function or how to using promises in this scenario. (username.value is the new username)</p>
  
  <pre><code>     //don't worry about the if statment, all it is doing is making sure that the element 
       //that stores the new username is not empty
       if(username.value != ""){
        db.collection("users").doc(doc.id).update({
          "name": username.value
        })  
        //How can I call this as soon as the username is set?
        //location.replace("../pages/homepage.html");
       }
  </code></pre>