I am looking to redirect to another page after a document has been written to firebase, what would be the best way of doing this? At the moment, I have something that looks like this:
var scoreRef = firebase.database().ref('scores');
scoreRef.push(myObj).then(() => {
document.location.href = "index.html";
});
I am using push to get a unique Id.
EDIT: Is there enough time for it to write to Firebase before it redirects?
CodePudding user response:
if you are using vanilla js than
location.href="URL"
or
location.replace("URL")
or
location.assign("URL")
are the three properties you can use.