I'm looking to redirect the user to another page once their name has been updated. The challenge I'm facing is knowing when to use my location.replace function and how to incorporate promises in this situation. (username.value represents the new username)
// Please disregard the if statement, it simply ensures that the element storing the new username isn't empty
if(username.value != ""){
db.collection("users").doc(doc.id).update({
"name": username.value
});
// How can I trigger this as soon as the username is set?
//location.replace("../pages/homepage.html");
}