My variables seem to be getting their values from the previous snapshot instead of the current one. No errors.
console logged variables right after snapshot and they don’t match with the PivId, but they do match the previous snapshot. The PivId is correct but the data is not. Very confused.
function getData() { //load data from Firebase data for selected pivot
console.log("get data")
const dbref = ref(db);
get(child(dbref, "myPivots/" + PivId)) //select child node path for selected pivot
.then((snapshot) => {
if (snapshot.exists()) {
Active = snapshot.val().active;
Bat = snapshot.val().bat;
Head = snapshot.val().head;
LastUpdate = snapshot.val().lastUpdate;
PrevHead = snapshot.val().prevHead;
StartDate = snapshot.val().startDate;
console.log(snapshot.val());
} else {
alert("No data found");
}
})
.catch((error) => {
alert(error)
})
console.log("Head "+ Head);
console.log("Bat "+ Bat);
}
console
https://drive.google.com/file/d/1NKaiH5j3LSRIQdJxVHiwlJqsnoznUcNL/view?
usp=sharing
firebase
https://drive.google.com/file/d/1dsvBtKJCtaU41ocru5xLqyZA1HXaLrd_/view?usp=sharing