Q:

How to show alert and refresh page simultaneously after response from Firebase?

Currently I am using firebase to store data and as soon as I get response from firebase, I need to show alert and refresh form page. Here is the code I am using for the purpose:
  // Push a new inquiry to the database using those values
  inquiry.push({
    "name": name,
    "contact": contact,
    "email": email,
    "board": board,
    "subject": subject,
    "standard": standard,
    "message": message,
  }).then(() => {
    alert("Thank You! Your request has been received and our team will connect with you shortly.");
});  

But the problem here is either the alert is shown OR the page is being refreshed. Both are not working simultaneously. So, my question here is how to show alert and refresh the form page one after another?

A:

The alert function is a blocking function. This means that when you run:

alert("hello"); 
console.log("hello again");

If you try it, you'll see that the hello again won't be logged, until you've pressed ok in the alert popup.
This means that you can just put the code that navigates after the alert in your then():
// Push a new inquiry to the database using those values
inquiry.push({
  "name": name,
  "contact": contact,
  "email": email,
  "board": board,
  "subject": subject,
  "standard": standard,
  "message": message,
}).then(() => {
  alert("Thank You! Your request has been received and our team will connect with you shortly.");
  location.reload();
}); 

