Hi all! I’m trying to figure out how to get this code to run in order. Apparently when I run this code, everything runs at the same time???
Example:
the field _scanned is initially false
wixData.get(“database”, “_id”)
.then((item) => {
console.log(item._scanned); //we expect this to be false here, but it’s true instead…
if (item._scanned === false ){
console.log(“false”); //this doesn’t even show
console.log(item); //nor this
item._scanned = true ; //but apparently these next 2 codes do run
wixData.update(type, item);
wixLocation.to(“/forum”); //and this one doesn’t…
}
else {
console.log(“true”); //this one does, even though when the page first load the value is false initially
}
})
Thanks in advance!